35 lines
823 B
PHP
35 lines
823 B
PHP
<?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!');
|
|
}
|
|
?>
|