Last active
August 26, 2019 15:58
-
-
Save nczz/dd8f7d264e660d4e8284c3d380266d59 to your computer and use it in GitHub Desktop.
使用 PHPMailer 解決輸出 MIME 格式的問題 https://www.mxp.tw/8635/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$service = new Google_Service_Gmail($client); | |
try { | |
$mail = new PHPMailer(); | |
$mail->CharSet = "UTF-8"; | |
$mail->From = "發信端信箱"; | |
$mail->FromName = "發信端別名"; | |
$mail->AddAddress("收信端信箱", "收信端別名"); | |
$mail->AddReplyTo("回信端信箱", "回信端別名"); | |
$mail->Subject = "信件主題"; | |
$mail->Body = "信件內文"; | |
$mail->isHTML(true); | |
$mail->preSend(); | |
$mime = $mail->getSentMIMEMessage(); | |
$mime = rtrim(strtr(base64_encode($mime), '+/', '-_'), '='); | |
$mensaje = new Google_Service_Gmail_Message(); | |
$mensaje->setRaw($mime); | |
$service->users_messages->send('me', $mensaje); | |
} catch (Exception $e) { | |
print($e->getMessage()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment