Name in the "from:" field ?

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
garethjax
Forum Newbie
Posts: 18
Joined: Mon Apr 23, 2007 7:16 am

Name in the "from:" field ?

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
Post Reply