[英]Reply to a specific thread
I'm trying to reply to a specific thread with Gmail API. 我正在尝试使用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". 它会将邮件发送到正确的邮件地址,但不会将其发送到使用“ threadId”指定的线程。
my threadId is 100% correct. 我的threadId是100%正确的。
Check the Sending messages documentation 查看发送消息文档
If you're trying to send a reply and want the email to thread, make sure that:
如果您要发送答复并希望发送电子邮件,请确保:
- The Subject headers match
主题标题匹配
- The References and In-Reply-To headers follow the RFC 2822 standard .
References和In-Reply-To标头遵循RFC 2822标准 。
Those are the parts you may be missing since you're almost correct. 这些是您可能会丢失的部分,因为您几乎是正确的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.