大佬教程收集整理的这篇文章主要介绍了node.js – 仅使用访问令牌使用Google API发送电子邮件,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
var request = require('request'); server.listen(3000,function () { console.log('%s listening at %s',server.name,server.url); // Base64-encode the mail and make it URL-safe // (replace all "+" with "-" and all "/" with "_") var encodedMail = new Buffer( "Content-Type: text/plain; charset=\"UTF-8\"\n" + "MIME-Version: 1.0\n" + "Content-transfer-encoding: 7bit\n" + "to: reciever@gmail.com\n" + "from: sender@gmail.com\n" + "subject: Subject Text\n\n" + "The actual message text goes here" ).toString("base64").replace(/\+/g,'-').replace(/\//g,'_'); request({ method: "POST",uri: "https://www.googleapis.com/gmail/v1/users/me/messages/send",headers: { "Authorization": "Bearer 'access_token'","Content-Type": "application/json" },body: JSON.Stringify({ "raw": encodedMail }) },function(err,response,body) { if(err){ console.log(err); // Failure } else { console.log(body); // success! } }); });
不要忘记更改接收方和发件人电子邮件地址以使示例正常工作.
以上是大佬教程为你收集整理的node.js – 仅使用访问令牌使用Google API发送电子邮件全部内容,希望文章能够帮你解决node.js – 仅使用访问令牌使用Google API发送电子邮件所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。