Last active
August 29, 2015 14:21
-
-
Save xdtianyu/7684a3d60e07a8391b4f to your computer and use it in GitHub Desktop.
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 | |
// Pear Mail Library | |
require_once "Mail.php"; | |
$event = $_POST['event']; | |
$name = $_POST['name']; | |
$time = date('Y-m-d H:i:s'); | |
$from = '<[email protected]>'; | |
$to = $_POST['email']; | |
$subject = "$name"." event notify"; | |
$body = "Hi, \n\n$name $event at $time\n\n------------\n\nThis mail is auto generated by mail api."; | |
$headers = array( | |
'From' => "$from", | |
'To' => "$to", | |
'Subject' => "$subject" | |
); | |
$smtp = Mail::factory('smtp', array( | |
'host' => 'ssl://smtp.gmail.com', | |
'port' => '465', | |
'auth' => true, | |
'username' => '[email protected]', | |
'password' => 'YOUR_EMAILS_APPLICATION_PASSWROD' | |
)); | |
$mail = $smtp->send($to, $headers, $body); | |
if (PEAR::isError($mail)) { | |
echo('<p>' . $mail->getMessage() . '</p>'); | |
} else { | |
#echo('Email sent!'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment