Skip to content

Instantly share code, notes, and snippets.

@typerandom
Created November 21, 2012 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typerandom/4127510 to your computer and use it in GitHub Desktop.
Save typerandom/4127510 to your computer and use it in GitHub Desktop.
Swift Mailer - Simple example
<?php
require_once 'lib/swift_required.php';
$transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25)
->setUsername('your username')
->setPassword('your password');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('john@doe.com' => 'John Doe'))
->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name'));
$message->setBody('<html>
<body>
<h2>Hi John!</h2><br><br>
Johanna (johanna82) sent you a message.<br>
<p>
Hi John. Amazing picture... <a href="http://www.awesome.com/msg/12345/read/">login and read the full message</a>
</p>
Best regards,<br>
Photos4Lulz
</body>
</html>');
if (!$mailer->send($message, $errors))
{
echo "Error:";
print_r($errors);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment