app.get('/email', function(req,res){
var emailjs = require('emailjs');
var email_server = emailjs.server.connect({
host: 'smtp.gmail.com',
ssl: true,
tls: true,
port: "465",
user:'kateholloway@gmail.com',
password:'mypassword',
});
var h={
text: 'hey how you doing',
from: 'Kate Holloway <kateholloway@gmail.com>',
to: 'someonesemail@gmail.com',
subject: 'where is your phone'
};
var message = emailjs.message.create(h);
email_server.send(message, function(err,message){
console.log(err);
console.log(message);
res.send('ok');
});
});
这是正确的设置吗?
我得到的错误信息是:
{ [Error: connection has ended] code: 9, smtp: undefined }
注意:此代码适用于我自己的域/服务器。但它不适用于 Gmail。因此,我认为我对 Gmail smtp 的设置不正确。