5

我正在使用 Gmail API 发送电子邮件。电子邮件已正确发送,但未显示发件人地址,因为我提到了 "Anup S via TestApp" 。相反,它只是显示用户 ID/电子邮件。

var email_lines = [];
email_lines.push("From: Anup S via TestApp <username@gmail.com>");
email_lines.push("To: to_user@gmail.com");
email_lines.push('Content-type: text/html;charset=iso-8859-1');
email_lines.push('MIME-Version: 1.0');
email_lines.push("Subject: New future subject here");
email_lines.push("");
email_lines.push("And the body text goes here");
email_lines.push("<b>And the bold text goes here</b>");

var email =email_lines.join("\r\n").trim();


var base64EncodedEmail = btoa(email);
var requestEmail = gapi.client.gmail.users.messages.send({
    'userId': "me", // I also tried changing this - and (obviously) it does not work. 
    'message': {
        'raw': base64EncodedEmail
    }
});

有想法该怎么解决这个吗?

4

2 回答 2

1

尝试添加'标记怎么样?

  email_lines.push("From: 'Anup S via TestApp' <username@gmail.com>");
于 2014-07-11T05:02:10.567 回答
0

发件人电子邮件地址必须与 API 的登录用户的电子邮件地址相匹配,不能是其他人。你的情况是这样吗?如果这是真的,那么您应该能够在您想要的电子邮件上设置任何显示名称,即:

email_lines.push("From: \"Some Name Here\" <myEmailAddr@gmail.com>");

于 2014-07-11T15:57:31.140 回答