PHPMailer 騰訊企業郵箱
用PHP連結企業郵箱寄送信件的程式Sample
$this->mail = new PHPMailer(true);
if(is_a($this->mail,”PHPMailer”)){
try {
$this->mail->isSMTP();
$this->mail->SMTPDebug = 0;
$this->mail->Host = “hwsmtp.exmail.qq.com”;
$this->mail->Port = 465;
$this->mail->SMTPSecure= “ssl”;
$this->mail->SMTPAuth = true;
$this->mail->SMTPKeepAlive=true;
//帳號
$this->mail->Username=”noreply@blahblah.com.xxx”;
//密碼
$this->mail->Password=”blahblah”;
//
$this->mail->setFrom($from_email, $from_name);
$this->mail->CharSet = mb_detect_encoding($contents);
$this->mail->addAddress($email, $to_name);
$subject = base64_encode($subject);
$subject = ‘=?utf8?B?’.$subject .’?=’;
$this->mail->Subject = $subject;
$this->mail->Body =$contents;
$this->mail->IsHTML(true);
//寄出
$this->mail->send();
} catch (phpmailerException $e) {
//echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
//echo $e->getMessage(); //Boring error messages from anything else!
}