better-staridc-MNBT
1<?php
2include("./MPHX/common.php");
3@header('Content-Type: text/html; charset=UTF-8');
4
5require './mail/vendor/autoload.php';
6use PHPMailer\PHPMailer\PHPMailer;
7
8function sendEmail($to, $subject, $message) {
9 global $DB,$conf;
10 $mail = new PHPMailer(true);
11 try {
12 $mail->isSMTP();
13 $mail->Host = $conf['mailhost'];
14 $mail->SMTPAuth = true;
15 $mail->Username = $conf['mailuser'];
16 $mail->Password = $conf['mailpassword'];
17 $mail->SMTPSecure = 'ssl';
18 $mail->Port = $conf['mailport'];
19 $mail->CharSet = 'UTF-8';
20
21 $mail->setFrom($conf['mailuser'], 'MN系统');
22 $mail->addAddress($to);
23 $mail->Subject = $subject;
24 $mail->Body = $message;
25
26 return $mail->send();
27 } catch (Exception $e) {
28 return false;
29 }
30}
31?>