【问题标题】:Sending email using google javascript API bounces使用 google javascript API 发送电子邮件被退回
【发布时间】: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


【解决方案1】:

原来问题是内容之前必须有一个额外的\r\n...

【讨论】:

    猜你喜欢
    • 2018-10-09
    • 2017-04-14
    • 1970-01-01
    • 2021-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-16
    相关资源
    最近更新 更多