Skip to content

Commit

Permalink
Create mail.php
Browse files Browse the repository at this point in the history
  • Loading branch information
xdtianyu committed Mar 30, 2018
1 parent 24093e4 commit 0fc5973
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions net/mail/mail.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
// Pear Mail Library
require_once "Mail.php";

$event = $_POST['event'];
$name = $_POST['name'];
$time = date('Y-m-d H:i:s');

$from = '<noreply.watcher@gmail.com>';
$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' => 'noreply.watcher@gmail.com',
'password' => 'YOUR_PASSWORD'
));
$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
echo('<p>' . $mail->getMessage() . '</p>');
} else {
#echo('Email successfully sent!');
}
?>

0 comments on commit 0fc5973

Please sign in to comment.