-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendMailFunctions.php
43 lines (33 loc) · 1.08 KB
/
sendMailFunctions.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
<?php
require_once "Mail.php";
require_once('Mail/mime.php');
function sendMail($to, $subj, $msgHtml, $msgTxt) {
$from = "[email protected]";
$to = $to;
$subject = $subj;
$message = new Mail_mime();
$message->setTXTBody($msgTxt);
$message->setHTMLBody($msgHtml);
$body = $message->get();
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "[email protected]";
$password = "M@ggie01";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$headers = $message->headers($headers);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
}
?>