Jump to:

23480 Posts in 18951 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Email: Reply-To

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1970 Views
  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Email: Reply-To Link to this post

    http://doc.silverstripe.org/doku.php?id=email

    I see how to set the "from" email address but I do not see how to set "Reply-To"

    This is done with plain PHP by sending special headers:
    'Reply-To: webmaster@example.com' . "\r\n"

    How can I do this in SilverStripe? My code does NOT work:

    $email = new Email($from, $to, $subject, $body);
    $email->reply_to = 'webmaster@example.com';
    $email->sendPlain();

  • Willr
    Avatar
    Forum Moderator
    5502 Posts

    Re: Email: Reply-To Link to this post

    reply to is a custom header - see php.net/manual/en/function.mail.php

    You need to call $email->addCustomHeader('Reply-To', 'something@something.com');

  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Re: Email: Reply-To Link to this post

    Thanks, willr, but your idea does not work. I tried your exact code but the custom header is not sent with the message.

    Do you have another idea, or could you point me to some documentation on SilverStripe custom email headers? Thanks!

  • Willr
    Avatar
    Forum Moderator
    5502 Posts

    Re: Email: Reply-To Link to this post

    Nope no idea then sorry. API docs for our email class are - http://api.silverstripe.com/default/Email.html but if addCustomHeader doesn't work then I have no clue

  • bonesbrigade
    Avatar
    Community Member
    10 Posts

    Re: Email: Reply-To Link to this post

    $From = "activate@sitename.com";
    $member = Member::currentUser();
    $To = $member->Email;
    $Subject = "(sitename) activation - last step before full profile control";
    $Body = "<p>$member->FirstName, please say hello to Heidi,
    <br />She will guide you through the rest of the activation project.
    <br />Be sure to send her some sample images of your art work as part of your activation!</p>";
    $email = new Email($From, $To, $Subject,$Body,null,null,"heidi@sitename.com");
    $email->addCustomHeader('Reply-To', 'heidi@sitename.com');
    //send mail
    $email->send();

    Took out site name since its still launching...

    But I will be sure to add it to the showcase - its a social networking site built 100% on silverstripe! Launches August 3rd 09- wish us luck!

    1970 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.