Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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('web@example.org', 'My site');
$mail->addTo('recipient@example.com', 'Their name');
$mail->setSubject('Test Subject');
$transport = new Mail\Transport\Sendmail();
$transport->send($mail);
// Swift Mailer
$message = Swift_Message::newInstance();
$message->setFrom(array(
'web@example.org' => 'My site',
));
$message->setTo(array(
'recipient@example.com' => '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
You can’t perform that action at this time.