Created
August 16, 2013 14:48
-
-
Save 1ik/6250565 to your computer and use it in GitHub Desktop.
Sending mail using swift mailer library
This file contains hidden or 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 'swift/lib/swift_required.php'; | |
// Create the Transport | |
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl") | |
->setUsername('gmailusername') | |
->setPassword('XXXXXXXXXX') | |
; | |
/* | |
You could alternatively use a different transport such as Sendmail or Mail: | |
// Sendmail | |
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs'); | |
$transport = Swift_MailTransport::newInstance(); | |
*/ | |
// Create the Mailer using your created Transport | |
$mailer = Swift_Mailer::newInstance($transport); | |
$message = Swift_Message::newInstance('Test Subject') | |
->setFrom(array('[email protected]' => 'YOUR NAME')) | |
->setTo(array('[email protected]')) | |
->setBody('From Localhost.'); | |
$result = $mailer->send($message); | |
print $result; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment