Created
June 4, 2013 14:14
-
-
Save anova/5706248 to your computer and use it in GitHub Desktop.
Send an e-mail via kriweb with swiftmailer. (This must work with other hostings)
**requires php 5.2
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 | |
//requires swiftmailer -> http://swiftmailer.org/ | |
include dirname(__FILE__) . '/vendor/swiftmailer/swift_required.php'; | |
/* values : begin */ | |
$sender_e_mail = 'sender@example.com'; | |
$sender_password = 'password'; | |
$sender_name = 'Example Sender'; | |
$subject = 'My Example Subject'; | |
$message = 'My example message content'; | |
$to_e_mail = 'to@example.com'; | |
$to_name = 'Example To'; | |
$cc_e_mail = 'to@example.com'; | |
$cc_name = 'Cc Example'; | |
/* values : end */ | |
$transporter = Swift_SmtpTransport::newInstance('mail.example.com', 25) | |
->setUsername($sender_e_mail) | |
->setPassword($sender_password); | |
$mailer = Swift_Mailer::newInstance($transporter); | |
$msg = Swift_Message::newInstance(); | |
$msg->setFrom(array( $sender_e_mail => $sender_name)); | |
$msg->setReplyTo(array($reply_to_e_mail => $reply_to_name)); | |
$msg->setTo(array($to_e_mail => $to_name)); | |
$msg->setCc(array($cc_e_mail => $cc_name)); | |
$msg->setSubject($subject); | |
$msg->setBody($message); | |
if($mailer->send($msg)): | |
echo 'success!'; | |
else: | |
echo 'fail!'; | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment