-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.php
executable file
·49 lines (40 loc) · 1.24 KB
/
mail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
require_once "Mail.php";
include('Mail/mime.php');
include 'config.php';
function send_mail(string $email, object $smtp, object $message) {
$crlf = "\r\n";
$headers = array(
'From' => $smtp->from,
'To' => $email,
'Subject' => $message->subject
);
$smtp = Mail::factory('smtp', array(
'host' => $smtp->host,
'port' => $smtp->port,
'auth' => true,
'username' => $smtp->username, //your gmail account
'password' => $smtp->password // your password
));
// Creating the Mime message
$mime = new Mail_mime($crlf);
// Setting the body of the email
$mime->setTXTBody($message->text);
$mime->setHTMLBody($message->html);
$body = $mime->get();
$headers = $mime->headers($headers);
// Send the mail
$mail = $smtp->send($email, $headers, $body);
//check mail sent or not
if (PEAR::isError($mail)) {
return false;
} else {
return true;
}
}
/* send_mail("[email protected]", $SMTP, (object) [ */
/* "subject" => "Please confirm your email", */
/* "text" => "Plain tet", */
/* "html" => "<html><body><p>HTML message</p><h2>This is not mere text</h2></body></html>" */
/* ]) */
?>