06.05.10 - Send and Email with Symfony and Swift Mailer

How to send an email from an action with Symfony 1.4 or 1.3

Symfony 1.4 or 1.3 comes integrated with Swift Mailer, we can send an email from every action with the next code:
//Mail creation
$mailer = Swift_Mailer::newInstance(Swift_MailTransport::newInstance());

//Message creation
$message = Swift_Message::newInstance('Subject')
  ->setFrom(array('user@test.com' => 'Username'))
  ->setTo(array('to@test.com' => 'Receiver name'))
  ->setBody('Email content')
;

//Send the email
$mailer->send($message);
More news about:  symfony
Tags:  email,  Swift Mailer

Comments

There are no comments jet. Be the first to comment!

Comment