如何使用SMTP添加OAuth 2.0身份验证以使用JavaScript发送电子邮件?
我需要在现有的电子邮件提交表格中添加OAuth 2.0安全性。我在网上找到了其他一些方法,但是当我使用SMTP时,我只想添加必要的代码和令牌。但是不知道如何正确编码。
JavaScript
function sendmail()
{
var name = $('#name').val();
var email = $('#email').val();
var subject = $('#subject').val();
var message = $('#message').val();
// var body = $('#body').val();
var Body='name: '+name+'<br>email: '+email+'<br>subject: '+subject+'<br>message: '+message;
//console.log(name, phone, email, message);
Email.send({
SecureToken : "",
To : '',
From : '',
Subject: "New message on contact from "+name,
Body: Body
}).then(
message =>{
//console.log (message);
if(message=='OK'){
alert('E-mail has been sent successfully. Thank you ...');
}
else{
console.error (message);
alert('Error at sending message ...')
}
}
);
}
当前只有此大量JavaScript代码使用SMTP协议发送电子邮件。但是Gmail正在禁用较低安全应用程序的访问。那么,我需要添加什么才能包括OAuth 2.0?
I need to add oauth 2.0 security in my existing email submission form. There are some other methods that I found online but as I am using smtp, I just want to add the necessary code and tokens. But don't know how to code it right.
JAVASCRIPT
function sendmail()
{
var name = $('#name').val();
var email = $('#email').val();
var subject = $('#subject').val();
var message = $('#message').val();
// var body = $('#body').val();
var Body='name: '+name+'<br>email: '+email+'<br>subject: '+subject+'<br>message: '+message;
//console.log(name, phone, email, message);
Email.send({
SecureToken : "",
To : '',
From : '',
Subject: "New message on contact from "+name,
Body: Body
}).then(
message =>{
//console.log (message);
if(message=='OK'){
alert('E-mail has been sent successfully. Thank you ...');
}
else{
console.error (message);
alert('Error at sending message ...')
}
}
);
}
Currently only this much javascript code is sending email using smtp protocol. But gmail is disabling access for less secure app. So what do I need to add to include oauth 2.0?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论