Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

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

Email: From Name


Reply

5 Posts   1751 Views

Avatar
DeklinKelly

9 July 2009 at 12:27pm Community Member, 197 Posts

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 the "from" name.

How can I make an email from "Foo Bar <foobar@example.com>" ?

$email = new Email($from, $to, $subject, $body);
$email->sendPlain();

Avatar
Willr

9 July 2009 at 6:41pm Forum Moderator, 5511 Posts

Chances are new Email(Foo Bar<foo@bar.com>, .... ) will work fine :)

Avatar
timwjohn

29 October 2009 at 1:54am (Last edited: 26 November 2009 12:26am), Community Member, 98 Posts

It's not working for me. It seems somewhere along the line extra angle brackets are added.

e.g. "Joe Bloggs <joe@bloggs.com>" is becoming "<Joe Bloggs <joe@bloggs.com>>" and the server throws the following:

[Warning] mail() [function.mail]: SMTP server response: 501 <Joe Bloggs <joe@bloggs.com>>: "@" or "." expected after "Joe"

Anyone else got this problem and/or a workaround?

Avatar
jhirm

9 March 2011 at 7:46am Community Member, 21 Posts

I'm having this problem too... seems uncommon, since there isn't much on the forum (or the googler) about it. I get an "Invalid email: \'From Name <fromname@fromserver.com>\'" when setting the from address like:

$from = "From Name <fromname@fromserver.com>";

Ideas?

Avatar
jhirm

9 March 2011 at 8:56am Community Member, 21 Posts

Just kidding! For me it was because I was using PHPMailer instead of the built-in mailer. Easily fixed.