Mail multipart/alternative vs multipart/mixed的答案表明附件应该是multipart/alternative消息的对等,如:
我想发送带有一些内嵌图像和纯文本替代品的html部分的电子邮件.各个部分的首选MIME布局是什么?在示例代码和其他问题中出现了几个选项,但哪些选项在实践中效果最好?我倾向于这样:
这样,图像显然是为了渲染html部分.一个完整的例子是:
From: Rich Example <rich-example@example.org>
To: A Recipient <recipient@example.org>
Subject: An example of email with images and a plain alternative
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="outer-boundary"
This is a MIME-encoded message. If you are seeing this, your mail
reader is old.
--outer-boundary
Content-Type: text/plain; charset=us-ascii
This message might make you :) or it might make you :( …Run Code Online (Sandbox Code Playgroud) 我正在使用https://github.com/google/google-api-php-client,我想发送一封包含用户授权的Gmail帐户的测试电子邮件.
这是我到目前为止:
$msg = new Google_Service_Gmail_Message();
$msg->setRaw('gp1');
$service->users_messages->send('me', $msg);
Run Code Online (Sandbox Code Playgroud)
这导致退回电子邮件,因为我不知道如何设置原始邮件.我在经过身份验证的用户的收件箱中看到了反弹.我想学习如何设置电子邮件的"收件人","抄送","密件抄送","主题"和"正文"的值.我相信我还需要对原始数据进行64位编码.我可能想在我的电子邮件正文中使用一些HTML.
请帮助提供使用gmail-api和google-api-php-client发送电子邮件的工作示例.
以下是收件箱中的退回电子邮件:
Bounce -nobody@gmail.com- 12:58 PM(7分钟前)
给我
发生错误.您的邮件未发送.,日期:星期四,2014年7月24日10:58:30 -0700消息ID:CABbXiyXhRBzzuaY82i9iODEiwxEJWO1 = jCcDM_TH-