Created
December 21, 2012 11:47
-
-
Save mattattui/4352338 to your computer and use it in GitHub Desktop.
Zend Mail and Swift Mailer examples
This file contains hidden or 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
<?php | |
// Zend Mail | |
use Zend\Mail; | |
$mail = new Mail\Message(); | |
$mail->setBody('This is the text of the email.'); | |
$mail->setFrom('[email protected]', 'My site'); | |
$mail->addTo('[email protected]', 'Their name'); | |
$mail->setSubject('Test Subject'); | |
$transport = new Mail\Transport\Sendmail(); | |
$transport->send($mail); | |
// Swift Mailer | |
$message = Swift_Message::newInstance(); | |
$message->setFrom(array( | |
'[email protected]' => 'My site', | |
)); | |
$message->setTo(array( | |
'[email protected]' => 'Their name', | |
)); | |
$message->setSubject('My subject'); | |
$message->setBody('Hello world', 'text/plain'); | |
$transport = Swift_MailTransport::newInstance(); | |
$mailer = Swift_Mailer::newInstance($transport); | |
$mailer->send($message); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment