Create mail.php
This commit is contained in:
parent
24093e4878
commit
0fc5973be1
|
@ -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!');
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue