我正在发送一封包含Gmail API和PHP的电子邮件。然而,当我发送消息时,消息中的所有链接都被删除了。 HTML [p]和[div' s]和[br&#; s]标签仍然存在但正在删除任何链接。不知道为什么会这样,这是我的代码:
$objGMail = new \Google_Service_Gmail($client);
$strRawMessage = "";
$boundary = uniqid(rand(), true);
$subjectCharset = $charset = 'utf-8';
$strMailContent = $array['body'];
$strRawMessage .= "\r\n--{$boundary}\r\n";
$strRawMessage .= 'Content-Type: text/html; charset=' . $charset . "\r\n";
$strRawMessage .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n\r\n";
$strRawMessage .= $strMailContent . "\r\n";
$mime = rtrim(strtr(base64_encode($strRawMessage), '+/', '-_'), '=');
$msg = new \Google_Service_Gmail_Message();
$msg->setRaw($mime);
$messageObj = $objGMail->users_messages->send("me", $msg);
$ array [' body']内容:
<a href="http://www.test.com" target="_blank">Test Site</a><br><br><br><br><div>My Signature<br>555-555-5555</div>
这里是&#34;显示原文&#34;来自我的Gmail帐户:
Received: from 12312312312 named unknown by gmailapi.google.com with HTTPREST; Fri, 1 Dec 2017 08:29:20 -0800 To: Me <myemail@gmail.com> From: Me <myemail@gmail.com> Subject: Test Email Message MIME-Version: 1.0 Content-type: multipart/mixed; boundary="asdfasdfasdfasdfasdf" Date: Fri, 1 Dec 2017 08:29:20 -0800 Message-Id: <asdfasdfasdfadsf=r_nHwnQF5LAtQ@mail.gmail.com>
--asdfasdfasdfasdfasdf Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Test Site<br><br><br><br><br><br><br><div class"email-signature">My Signature<br>555-555-5555</div>
--asdfasdfasdfasdf--