Created
November 21, 2012 20:39
-
-
Save typerandom/4127510 to your computer and use it in GitHub Desktop.
Swift Mailer - Simple example
This file contains 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 | |
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('[email protected]' => 'John Doe')) | |
->setTo(array('[email protected]', '[email protected]' => '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