-
Notifications
You must be signed in to change notification settings - Fork 12
/
email.php
55 lines (39 loc) · 1.32 KB
/
email.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
50
51
52
53
54
55
<?php
// This requires PHPMailer
// You can get it here: https://github.com/Synchro/PHPMailer
// either copy the folder (renamed to phpmailer in this case) to this directory
// or add it to your include_path and delete the phpmailer/ below
//include("phpmailer/class.phpmailer.php");
require "phpmailer/PHPMailerAutoload.php";
include_once("config.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = $smtpserver;
$mail->Port = $smtpport;
$mail->SMTPAuth = $smtpauth;
$mail->Username = $smtpuser;
$mail->Password = $smtppass;
$mail->SMTPSecure = $smtpenc;
// TODO: finish this, though not sure if I'll need it
function email_user($userid, $subject, $body) {
//send_email($useremail, $subject, $body);
}
// because using mail function might not always be best
function send_email($email, $subject, $body) {
//$headers = "From: [email protected]\r\n".
// "Reply-To: [email protected]";
//mail($email, $subject, $body, $headers);
global $mail, $fromemail;
$mail->From = $fromemail;
$mail->FromName = $fromemail;
$mail->AddAddress($email);
$mail->IsHTML(true);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AltBody = $body;
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
//exit;
}
}