我想得到一些帮助,因为我现在有点迷路了。我正在尝试通过可恢复上传的方式将附件与我的电子邮件一起发送。但当我在收件箱中查看电子邮件时,我看不到任何文件。所以我可能忘了什么。
这是我的密码。所以如果有人看到什么^^
$send_data = 'From: <FROM_EMAIL>' . "n";
$send_data = 'To: <TO_EMAIL>' . "n";
$send_data = 'Subject: <SUBJECT>' . "n";
$send_data = '' . "n";
$send_data = '<MY MESSAGE>' . "n";
$send_data= rtrim(strtr(base64_encode($send_data), '+/', '-_'), '=');
$msg = new Google_Service_Gmail_Mesage();
$msg->setRaw($send_data);
$this->client->setDefer(true);
$request = $this->service->users_messages->send('me', $msg, array('uploadType' => 'resumable'));
$chunkSizeBytes = 1 * 1024 * 1024;
$media = new Google_Http_MediaFileUpload(
$this->client,
$request,
'message/rfc822',
null,
true,
$chunkSizeBytes
);
$media->setFileSize(filesize(TEST_FILE));
$status = false;
$handle = fopen(TEST_FILE, "rb");
$i = 0;
while (!$status && !feof($handle)) {
$chunk = fread($handle, $chunkSizeBytes);
$status = $media->nextChunk($chunk);
}
$result = false;
if($status != false) {
$result = $status;
}
fclose($handle);
$this->client->setDefer(false);
感谢
我对gmailapi了解不多,但我觉得setRaw()需要你编写完整的电子邮件(包括附件),而不仅仅是"正文"。