Small article just to show emails in symfony, I read a lot things, good and less good on the emails in symfony, that what did I learn:
- SwiftMailer is integrated with Symfony since sf 1.3
- To create an email, you must first instantiate a mailer, it is done with this command: $ mailer =
sfContext: : getInstance () -> getMailer ();
- to construct the email, using the method compose () mailer
$ message = $ this-> getMailer () -> compose (email @ destination.com 'email@source.com', 'My Subject', 'my content');
can also make nice emails using symfony views using the method setBody () Message
$ Message-> setBody ($ this-> getPartial ('myPartialView', array ("variable1" => "1")), 'text / html');
- To send this message, we use the send () method of the mailer, passing as parameters the message, the email recipient, email response
$ mailer-> send ($ message, $ emailTarget, $ emailReply)
For more information on emails with Symfony such as configuration items of mail, the mode of distribution, shipping etc., please visit the book Symfony "The More With symfony, page 4"
0 comments:
Post a Comment