Page 1 of 1

Name in the "from:" field ?

Posted: Fri May 04, 2007 5:38 am
by garethjax
Ok it may sound a newbie question, but i can't figure it out...

I'm trying to show the "name" of the user sending the email in the from: field.

I've been using a variable $from with a content like
$from = "Username <postmaster@mydomain.com>"; //sender

But it seems that Swiftmailer ignore the part outside the <email> part.

Posted: Fri May 04, 2007 5:40 am
by Chris Corbyn

Code: Select all

$from = new Swift_Address("postmaster@mydomain.com", "Username");
It's just a way of ensuring compliancy with RFC 2822 and reducing your risk of being blocked as spam. You can use Swift_Address in any of the address headers too.