【发布时间】:2017-06-22 20:35:57
【问题描述】:
我正在尝试使用 JS google API 发送电子邮件。初始化很顺利,但是当我尝试发送电子邮件时,它会弹回来说“发生错误。您的消息未发送”,没有任何其他数据。
我发送测试邮件的代码:
let email = 'To:luoruize@gmail.com\r\n';
email += 'Subject:Testing\r\n';
email += 'This is a test!';
const message = window.btoa(email).replace(/\+/g, '-').replace(/\//g, '_');
gapi.client.gmail.users.messages.send({
userId: 'me',
resource: {
raw: message
}
}).execute((res) => {
console.log(res);
});
我做错了什么?
【问题讨论】:
-
尝试使用JavaScript Quickstart来熟悉如何设置Gmail API、OAuth 2.0 Authentication以及Google给出的cade示例的基本流程。我还找到了Sending Emails with the Gmail JavaScript API 的教程,该教程还提供了从启用 API 到初始设置然后发送电子邮件的详细信息。希望这会有所帮助。
标签: javascript email gmail-api google-api-js-client