Sharanabasu Angadi
Sharanabasu Angadi

Reputation: 4382

Nodemailer not working on Amazon EC2 instance

I am EC2 instance up and running , I wanted to integrate nodemailer in my application. Following the https://www.npmjs.com/package/nodemailer I was able to send email from my localhost. When the same code I integrated on EC2 instance I am getting Invalid login error . Sometime gmail blocks login from other application and send confirm mail to the inbox. I didnt get any such mail also. Do I need to enable some port on EC2 instance or I can use nodemailer at all on EC2 instance. Please suggest

Upvotes: 7

Views: 6794

Answers (2)

vijay
vijay

Reputation: 11027

No need to enable aws ses service

Open port : 465 on aws(e2c) instance in outbound section.

Test if port really opened : with nmap command nmap 14.247.74.33.

Note : do not proceed until you see open ports like

Starting Nmap 5.21 ( http://nmap.org ) at 2012-08-15 19:01 IST
Nmap scan report for 14.247.74.33
Host is up (0.058s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE
23/tcp open  telnet
80/tcp open  http
465    open 

Simple nodemailer configuration works

const transporter = nodemailer.createTransport({
    service: 'gmail',
    host: 'smtp.gmail.com',
    port: 465,
    secure: true,
    auth: {
        user: EMAIL_ID,
        pass: EMAIL_PASSOWRD,
    },
});

Full example code

Upvotes: 2

300D7309EF17
300D7309EF17

Reputation: 24653

Gmail is not a production SMTP service. Configure nodemailer to send mail from a production mailer, such as AWS Simple Email Service. Like gmail, SES is a "well-known service" in nodemailer. There's a great example of using SES in the nodemailer README.

Upvotes: 1

Related Questions