Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
使用 PHPMailer 解決輸出 MIME 格式的問題 https://www.mxp.tw/8635/
<?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
You can’t perform that action at this time.