php - How to change the name text of sender when sending mail with Swift_Message? -



php - How to change the name text of sender when sending mail with Swift_Message? -

i using swiftmailer send emails application.

all working fine far. need able alter text of sender dynamically. code snippet below , next paragraph should clarify mean.

currently, code looks this:

try{ $message = swift_message::newinstance() ->setfrom($from) ->setto($to) ->setsubject($subject) ->setbody($content); $mailer->send($message); }catch (exception $e) { // ... }

the $from variable contains email address of sender - sysmail@mydomain.com

however, want send daily digests (for example) different entities (example forums, groups etc), want able set name text of sender 'forum abc members daily digest', though sender still sysmailer@mydomain.com. notice linkedin doing similar - send out different digests under different sender names, though sender group-digests@linkedin.com.

the default name sysmailer@mydomain.com 'system mailer'. incidentally, using google apps mailing service provider. not practical me setup different user accounts, users can create own forums etc.

is there way whereby can dynamically (i.e. via code) specify sender name, although using same sender email address?

you have pass $from array.

$from = array($from_email => $from_name); try{ $message = swift_message::newinstance() ->setfrom($from) ->setto($to) ->setsubject($subject) ->setbody($content); $mailer->send($message); }catch (exception $e) { // ... }

where alter $from_name each of mailers.

hope helps!

php email swiftmailer

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -