I have an AWS EC2 with port 25 opened. Here is my code:
var nodemailer = require("nodemailer");
var smtp = {
server: 'email-smtp.us-east-1.amazonaws.com',
username: 'SMTPUSERNAMEXXXX',
password: 'SMTPPASSWORD'
}
var mailOptions = {
from: "Murvin Lai [email protected]", // sender address
to: "[email protected]", // list of receivers
subject: "Hello", // Subject line
text: "Hello world", // plaintext body
html: "Hello world" // html body
}
var transport = nodemailer.createTransport("SMTP", {
host: smtp.server,
auth: {
user: smtp.username,
pass: smtp.password
}
});
transport.sendMail(mailOptions, function(err, data) {
if (err) {
console.log("Error: " + err);
} else {
console.log("Sent: " + data.message);
}
});
I run this and I got this error:
Error: Error: connect ECONNREFUSED
I inspect the error and this is the detail:
{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
by the way, I have verified my email. Also, if I run it with SES ( with access id & key), it works.
So, what's the problem in my SMTP call?
Figure out.
how did you figure this out? I have a similar issue.
thanks
It is a working piece of code. The problem was the SMTP password. I think when I didn't copy the entire thing and caused the problem. And also, I was in AWS sandbox mode, so, I verified the sender, but not the recipient. After I verified that, it worked.
I can run this locally on my mac, but on my server it won't work. I assume
then its not the password.
Thanks
On Monday, 23 September 2013, Murvin Lai wrote:
It is a working piece of code. The problem was the SMTP password. I think
when I didn't copy the entire thing and caused the problem. And also, I was
in AWS sandbox mode, so, I verified the sender, but not the recipient.
After I verified that, it worked.—
Reply to this email directly or view it on GitHubhttps://github.com/andris9/Nodemailer/issues/161#issuecomment-24939329
.
Mr Hugh Halford-Thompson
+44 (0)7789231917
http://www.quickbitcoin.co.uk/
http://hughht5.blogspot.co.uk/ http://www.techcrunchlite.com/
Flat 2
Minus One House
Lyttleton Road
Leyton
E10 5NQ
UK
Too brief? Here's why! http://emailcharter.org
check the security. You need to open up port 25 from your server. :)
@hughht5 How u fixed it?
I have the same problem.
@ZeuCxb have you check the port and security settings (e.g. firewall)
@murvinlai In my case the code work in localhost, but when i try in production the same code returns ECONNREFUSED. I don`t know if is a error or a problem with aws or in my smtp server.
I think it was the firewall. It was a long time ago though so not sure.
On Fri, 17 Jun 2016 at 18:46, Eliseu Benedito Codinhoto <
[email protected]> wrote:
@murvinlai https://github.com/murvinlai In my case the code work in
localhost, but when i try in production the same code returns ECONNREFUSED.
I don`t know if is a error or a problem with aws or in my smtp server.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/nodemailer/nodemailer/issues/161#issuecomment-226835244,
or mute the thread
https://github.com/notifications/unsubscribe/AAmZwusmpM2JD8kZyKNI3-S8rv5b7zN4ks5qMt12gaJpZM4Ar7xE
.
[email protected] / +44 7789 231 917
Blockchain Tech Ltd
+1 855 256 5246
http://blockchaintechltd.com
[image: Twitter] https://twitter.com/blockchainltd [image:
Facebook] https://www.facebook.com/blockchaintechltd [image: LinkedIn]
https://www.linkedin.com/company/blockchain-tech-ltd
IMPORTANT MESSAGE FROM BLOCKCHAIN TECH LTD. (BTL)*
(1) The information in this email and any attachments are confidential. If
you are not the intended recipient, you may not use, distribute, disclose
or copy this email, whether in printed or electronic form. If you received
this email by mistake, please immediately notify the sender by replying to
this message and delete all copies of this email in your possession. Please
accept our apologies and thank you. (2) Any opinions or views expressed in
this email are solely the responsibility of the author and do not
necessarily represent those of BTL. BTL will not accept any liability in
respect of communications that are contrary to BTL policy. (3) Finally, BTL
takes reasonable steps to ensure this email is malware free, however, the
recipient is ultimately responsible for checking this email for malware.
BTL, therefore accepts no liability for any damage caused by any malware
transmitted with this email. "Email" means the body of the message and any
attachments.
it seems like security policy not set properly. by default, port 25 is not opened, you need to allow it. Have you tried the steps I posted above?
@murvinlai Yeah i try, i just don`t understand why the server can sand emails using gmail :l
@murvinlai @hughht5 Thanks, i just changed smtp to smtpi and it worked
Not working on EC2 instance.
All of my instance ports are open.
var transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: 'iam****[email protected]', pass: ' ' } });
After making 3 changes from Google Account its finally working.
:)
Most helpful comment
After making 3 changes from Google Account its finally working.
:)