Last active
August 29, 2015 14:21
-
-
Save christoph-hautzinger/2e0d00612a84dd5ab5c5 to your computer and use it in GitHub Desktop.
sending mails symfony standard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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