-
Notifications
You must be signed in to change notification settings - Fork 0
/
5c_email_lib.php
59 lines (43 loc) · 1.36 KB
/
5c_email_lib.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
56
57
58
59
<?php
//header('Access-Control-Request-Method: *');
//header('Access-Control-Allow-Origin:'.$_SERVER['HTTP_ORIGIN']);
function send_message($SendMailFrom, $SendMailTo, $SMTPHost, $SMTPPort, $SMTPUser, $SMTPPassword, $SMTPSecure, $SMTPDebug, $subject, $body) {
$result='1';
if( !isset($subject) ) $subject='';
if( !isset($body) ) $body='';
# Send message
require_once('class.phpmailer.php');
require_once('class.smtp.php');
try{
$mail=new PHPMailer(true);
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = $SMTPHost;
$mail->SMTPSecure = $SMTPSecure;
$mail->SMTPDebug = $SMTPDebug;
$mail->Port = $SMTPPort;
$mail->Username = $SMTPUser;
$mail->Password = $SMTPPassword;
$mail->From = $SendMailFrom;
$mail->FromName = $SendMailFrom;
$mail->Subject = $subject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->CharSet = 'UTF-8';
$mail->MsgHTML($body);
if( is_array($SendMailTo) ) {
foreach($SendMailTo as $CurrentAddressKey => $CurrentAddressValue) {
$mail->AddAddress($CurrentAddressValue);
}
}
elseif( is_string($SendMailTo) ) {
$mail->AddAddress($SendMailTo);
}
$mail->Send();
$result='0';
}
catch(Exception $e){
$result=($e->getMessage());
}
return($result);
}
?>