Created
August 13, 2013 20:27
-
-
Save jptoto/6225332 to your computer and use it in GitHub Desktop.
Swift PHP Mailer 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'; | |
// Create the Transport | |
$transport = Swift_SmtpTransport::newInstance('staging-smtp.postmarkapp.com', 2525) | |
->setUsername('api_key') | |
->setPassword('api_key') | |
; | |
/* | |
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); | |
// Create a message | |
$message = Swift_Message::newInstance('Test from Swift 5') | |
->setFrom(array('email5@email.com' => 'JP Toto')) | |
->setTo(array('email4@email.com')) | |
->setBody('Here is the message itself') | |
->setCc(array('email3@email.com')) | |
->setBcc(array('email2@amil.com', 'email@email1.com')) | |
; | |
// Send the message | |
$result = $mailer->send($message); | |
print $result; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment