Repository navigation
Expand file tree
/
Copy pathclass.sendmail.php
More file actions
61 lines (52 loc) · 1.77 KB
/
Copy pathclass.sendmail.php
File metadata and controls
61 lines (52 loc) · 1.77 KB
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
60
61
<?php
/* ~ class.sendemail.php
.---------------------------------------------------------------------------.
| must: open extension=php_openssl.dll|open ssl
| |
| must: Send mail server to open SMTP service
|
'---------------------------------------------------------------------------'
*/
include("class.phpmailer.php");
include("class.smtp.php");
class sendmail {
/**
* Constructor
* @param boolean $exceptions Should we throw external exceptions?
*/
public function __construct($exceptions = false) {
$this->exceptions = ($exceptions == true);
}
public function send_email($from, $to, $subject, $send_body, $password) {
// loop thru multiple email recipients if more than one listed --- (esp for the admin's "Extra" emails)...
foreach (explode(',', $to) as $key => $value) {
$to = trim($value);
$smtp = 'smtp.qq.com';
$port = 465;
$username = $from;
$mail = new phpmailer();
$mail->IsSMTP();
//$mail->SMTPDebug = true;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = $smtp;
$mail->Port = $port;
$mail->CharSet = "UTF-8"; //字体
$mail->Username = $username;
$mail->Password = $password;
$mail->From = $from;
$mail->FromName = $from;
$mail->Subject = $subject;
$mail->Body = $send_body;
$mail->IsHTML(true);
$mail->AddAddress($to);
if (!$mail->Send()) {
echo "error!" . $mail->ErrorInfo;die;
}
// else {
// echo "success!";
// }
// die;
}
}
}