1
我想使用JS谷歌API发送电子邮件。初始化进行的很顺利,但是当我尝试发送一封电子邮件时,它会反弹说没有任何额外的数据就会发出“发生错误,您的邮件未发送”。使用谷歌JavaScript API发送电子邮件
我发送测试电子邮件代码:
let email = 'To:[email protected]\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的快速入门(https://developers.google.com/gmail/api/quickstart/js)熟悉如何设置Gmail API,OAuth 2.0身份验证和Google提供的cade示例的基本流程。我还发现了一篇关于[使用Gmail JavaScript API发送电子邮件]的教程(https://www.sitepoint.com/sending-emails-gmail-javascript-api/),本教程还提供了一个详细介绍,使您的API可以初始设置然后发送电子邮件。希望这可以帮助。 –