1

I am using nodemailer in node.js express app. I am sending email perfectly using nodemailer from my gmail. But the problem is I don't want to mention my gmail and smtp it throws smtp error when tried to send from aws server. so now I want make default like (ex: noreply@mail.com) so it should send from my localhost andfrom aws server also f I host in aws server.

can you please tell me how can I do it.

I tried this way

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);
                });

I get this error:

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
Carlos
  • 458
  • 12
  • 23

1 Answers1

-1

You can use the Mailgun mail server to send your emails they have a free plan. This how you can send a email with nodemail and mailgun.

user3254198
  • 763
  • 6
  • 23