如何在aws服务器中使用nodemailer发送邮件
问题描述:
我在node.js express应用程序中使用nodemailer。我使用我的Gmail中的nodemailer完美发送电子邮件。但问题是我不想提及我的gmail和smtp它试图从aws服务器发送时抛出smtp错误。所以现在我想让默认像(例如:[email protected])所以它应该从我的本地主机和aws服务器发送也我主机在aws服务器。如何在aws服务器中使用nodemailer发送邮件
你能告诉我我该怎么做。
我试过这样
aws.config.loadFromPath('aws-config.json');
const transporter = nodemailer.createTransport({
SES: new aws.SES({
apiVersion: '2017-12-01'
})
});
// setup email data with unicode symbols
const mailOptions = {
from: '[email protected]',
to: req.body.email,
subject: 'Message',
text: 'I hope this message gets sent!',
};
transporter.sendMail(mailOptions, (err, info) => {
if (err) {
console.log('Error: ', err);
}
console.log('info: ', info);
// console.log(info.messageId);
});
我得到这个错误:
Error: { Error: connect ECONNREFUSED 127.0.0.1:25
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 25 }
info: undefined