Skip to content

Instantly share code, notes, and snippets.

@mattattui
Created December 21, 2012 11:47
Show Gist options
  • Save mattattui/4352338 to your computer and use it in GitHub Desktop.
Save mattattui/4352338 to your computer and use it in GitHub Desktop.
Zend Mail and Swift Mailer examples
<?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