您好我通过谷歌的GMail API发送电子邮件,如下所示:
$strRawMessage = "From: Name <good@email.com>\r\n";
$strRawMessage .= "To: Another Name <anothergood@email.com>\r\n";
$strRawMessage .= 'Subject: =?utf-8?B?' . base64_encode('Subject') . "?=\r\n";
$strRawMessage .= "MIME-Version: 1.0\r\n";
$strRawMessage .= "Content-Type: text/html; charset=utf-8\r\n";
$strRawMessage .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n\r\n";
$strRawMessage .= 'Content<img src="http://example.com/img.jpg">';
$strRawMessage .= "\r\n";
$mime = rtrim(strtr(base64_encode($strRawMessage), '+/', '-_'), '=');
$msg = new Google_Service_Gmail_Message;
$msg->setRaw($mime);
$response = $service->users_messages->send($userId, $msg);
它有效。邮件位于已发送文件夹中,收件人会收到电子邮件。但是我发现在标题中有一些有线的东西,如:
Received: from 610088504391 named unknown by gmailapi.google.com with HTTPREST; Wed, 15 Feb 2017 12:17:37 -0800
或
Received: from mx.example.com (unresolved [10.174.34.83]:35438)
by ps8 (Ota) with LMTP id 1C2A929C5BB61
但我从未使用过mx.example.com而且我不知道10.174.34.83的ip地址......
GMail将我的<img src=...>
标记更改为<img>
,因此会破坏代码。知道为什么会这样吗?