Skip to content

Instantly share code, notes, and snippets.

@xdtianyu
Last active August 29, 2015 14:21
Show Gist options
  • Save xdtianyu/7684a3d60e07a8391b4f to your computer and use it in GitHub Desktop.
Save xdtianyu/7684a3d60e07a8391b4f to your computer and use it in GitHub Desktop.
<?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