我在node.js express app中使用nodemailer。我正在使用来自我的Gmail的nodemailer完美地发送电子邮件。但问题是我不想提及我的gmail和smtp它在尝试从aws服务器发送时会抛出smtp错误。所以现在我想要默认为( ex:noreply@mail.com ),所以它应该从我的localhost和aws服务器发送,也可以在aws服务器中托管。
你可以告诉我我该怎么做。我试过这种方式
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: 'noreply@abc.com',
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