【问题标题】:How to send mail using nodemailer in aws server如何在 aws 服务器中使用 nodemailer 发送邮件
【发布时间】:2025-11-27 08:25:02
【问题描述】:

我在 node.js express 应用程序中使用 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

【问题讨论】:

    标签: node.js nodemailer


    【解决方案1】:

    您可以使用Mailgun 邮件服务器发送您的电子邮件,他们有免费计划。这样你就可以send a email with nodemail and mailgun

    【讨论】:

      最近更新 更多