Reply to a specific thread

孤街浪徒 提交于 2019-12-12 04:53:40

问题


I'm trying to reply to a specific thread with Gmail API.
Here's my code:

$strRawMessage = "From: Firstname lastname <".$userId.">\r\n";
$strRawMessage .= "To: Firstname lastname <tomail@gmail.com>\r\n";
$strRawMessage .= 'Subject: =?utf-8?B?' . base64_encode("Heres my test message") . "?=\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 .= "this <b>is a test message!\r\n";

$mime = rtrim(strtr(base64_encode($strRawMessage), '+/', '-_'), '=');
$msg = new Google_Service_Gmail_Message();
$msg->setRaw($mime);
$msg->setThreadId( $threadId );

$response = $this->service->users_messages->send($userId, $msg);

It sends the mail to the correct mail address but won't send it to the thread specified with "threadId".

my threadId is 100% correct.


回答1:


Check the Sending messages documentation

If you're trying to send a reply and want the email to thread, make sure that:

  1. The Subject headers match
  2. The References and In-Reply-To headers follow the RFC 2822 standard.

Those are the parts you may be missing since you're almost correct.



来源:https://stackoverflow.com/questions/45962805/reply-to-a-specific-thread

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!