Skip to content

Instantly share code, notes, and snippets.

@christoph-hautzinger
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christoph-hautzinger/2e0d00612a84dd5ab5c5 to your computer and use it in GitHub Desktop.
Save christoph-hautzinger/2e0d00612a84dd5ab5c5 to your computer and use it in GitHub Desktop.
sending mails symfony standard
public function indexAction($name)
{
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send@example.com')
->setTo('recipient@example.com')
->setBody(
$this->renderView(
// app/Resources/views/Emails/registration.html.twig
'Emails/registration.html.twig',
array('name' => $name)
),
'text/html'
)
->addPart(
$this->renderView(
'Emails/registration.txt.twig',
array('name' => $name)
),
'text/plain'
)
;
$this->get('mailer')->send($message);
return $this->render(...);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment