Create mail.php

This commit is contained in:
tianyu 2018-03-30 23:58:45 +08:00 committed by GitHub
parent 24093e4878
commit 0fc5973be1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 0 deletions

34
net/mail/mail.php Normal file
View File

@ -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!');
}
?>