[英]nodemailer email login invalid
{ [Error: Invalid login: 535 5.0.0 Authentication Failed] code: 'EAUTH', response: '535 5.0.0 Authentication Failed',
{[[错误:无效的登录:535 5.0.0身份验证失败]代码:'EAUTH',响应:'535 5.0.0身份验证失败',
responseCode: 535 }responseCode:535}
It keeps giving me this error, tried several times with different tutorials and still not working.... 它一直给我这个错误,尝试了几次不同的教程,但仍然无法正常工作。
Also I know it will be hard to access to gmail's authentication and on top of that my gmail has two steps secure validation, so I decided to use Hotmail instead... 我也知道很难访问gmail的身份验证,最重要的是我的gmail有两步安全验证,因此我决定改用Hotmail ...
Here is code for my index.html 这是我的index.html的代码
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script><script>
<script>
$(document).ready(function(){
var from,name,email,subject,text;
$("#submit").click(function(){
name=$("#name").val();
email=$("#email").val();
subject=$('#subject').val();`enter code here`
text=$("#message").val();
$("#messages").text("Sending E-mail...Please wait");
$.get("http://localhost:8000/send",{name:name,email:email,subject:subject,text:text},function(data){
if(data=="sent")
{
$("#messages").empty().html("
Email is been sent at "+to+" . Please check inbox !
");
}
});
});
});
</script>
below is my server.js code 以下是我的server.js代码
var express = require('express');
var path = require('path');
var app = express();
var nodemailer = require("nodemailer");
app.use(express.static('assets'));
var smtpTransport = nodemailer.createTransport({
service: 'Hotmail',
auth: {
user: 'myemail.com',
pass: 'something'
}
});
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
app.get('/send', function(req, res){
var mailOptions={
from: "ME <my@hotmail.com>",
name : req.query.name,
To: req.query.email,
subject: req.query.subject,
text: req.query.message
};
console.log(mailOptions);
smtpTransport.sendMail(mailOptions, function(error, response){
if(error){
console.log(error);
res.end("error");
}else{
console.log("Message sent: " + response.message);
res.end("sent");
}
});
});
app.listen(8000, function(){`enter code here`
});
Hotmail might block connections from unexpected geographical locations, check your account security overview to see if you need to confirm any login attempts. Hotmail可能会阻止来自意外地理位置的连接,请查看您的帐户安全概述,以查看是否需要确认任何登录尝试。
Additionally, if you use 2-factor auth for Hotmail then you need application specific password for Nodemailer, you can't use your account password in this case. 此外,如果您对Hotmail使用2因子身份验证,则需要Nodemailer的应用程序专用密码,在这种情况下,您将无法使用帐户密码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.