I try to use gmail API to send emails form node application. Here is my code:
function sendEmail(auth) {
var gmail = google.gmail('v1');
gmail.users.messages.send({
auth,
userId: 'me',
resource: {
payload: {
mimeType: 'message/rfc822',
headers: [{name: 'To', value: 'ayeritsian@gmail.com'},
{name: 'Subject', value: 'test'},
{name: 'From', value: 'ayeressian2@gmail.com'}]
},
raw: new Buffer('test123').toString('base64')
},
internalDate: Date.now()
}, function (err, bla, IncommingMessage) {
console.log(arguments);
console.log('end');
});
}
When I run the application I keep getting bounce messages "An error occurred. Your message was not sent.". The error message is not descriptive enough and there is almost no documentation for google-api node package. I will appreciate it if someone can help me out.