简体   繁体   中英

Sending email using google javascript API bounces

I'm trying to use the JS google API to send emails. The initialization goes well, but when I try to send an email, it bounces back saying "An error occurred. Your message was not sent" without any additional data.

My code for sending a test email:

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);
});

What am I doing wrong?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM