1
{ [Error: Invalid login: 535 5.0.0 Authentication Failed] code: 'EAUTH', response: '535 5.0.0 Authentication Failed',
responseCode: 535 }nodemailer郵箱登錄無效
它不斷給我這個錯誤,試了好幾次不同的教程和仍然沒有工作....
而且我知道這將是很難訪問Gmail的認證,然後在上面那我的Gmail有兩個步驟的安全驗證,所以我決定用Hotmail的,而不是...
這裏是代碼爲我的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>
下面
是我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 <[email protected]>",
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`
});