Skip to content

Instantly share code, notes, and snippets.

@pedro-vasconcelos
Created May 9, 2014 11:13
Show Gist options
  • Select an option

  • Save pedro-vasconcelos/280a12a9cc7b11b0dac3 to your computer and use it in GitHub Desktop.

Select an option

Save pedro-vasconcelos/280a12a9cc7b11b0dac3 to your computer and use it in GitHub Desktop.
Code to send e-mail with Swiftmailer and Amazon SES
require "swift-mailer-510/lib/swift_required.php";
$message = Swift_Message::newInstance()
->setCharset('utf-8')
->setSubject('Your subject')
->setFrom(array('from@example.com' => 'From Name'))
->setTo(array('to@example.com' => 'To Name'))
->setBody('Here is the message itself')
->addPart('<q>Here is the message itself</q>', 'text/html')
;
$transport = Swift_SmtpTransport::newInstance('http://email-smtp.us-east-1.amazonaws.com', 587, 'tls')
->setUsername('Amazon STMP Username')
->setPassword('Amazon STMP Password')
;
#$transport = Swift_MailTransport::newInstance();
$mailer = Swift_Mailer::newInstance($transport);
$result = $mailer->send($message);
var_dump($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment