Nodemailer: SMTP with cPanel based emails doesn't work.

Created on 18 Jun 2015  Β·  5Comments  Β·  Source: nodemailer/nodemailer

Hi,

Firstly thanks for the great tool you made. I was working on using it with cPanel's email id on shared server. I ended up with these logs

SERVER 1:
└──220-md-in-6.webhostbox.net ESMTP Exim 4.85 #2 Thu, 18 Jun 2015 09:12:14 +0000
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
CLIENT 1:
└──EHLO [127.0.0.1]
SERVER 1:
└──250-md-in-6.webhostbox.net Hello [127.0.0.1] [182.69.86.155]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
CLIENT 1:
└──STARTTLS
SERVER 1:
└──220 TLS go ahead
Connection secured
CLIENT 1:
└──EHLO [127.0.0.1]
SERVER 1:
└──250-md-in-6.webhostbox.net Hello [127.0.0.1] [182.69.86.155]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250 HELP
CLIENT 1:
└──AUTH PLAIN AGluZm9Ac29sb21vZnkuY29tAEI5XlR3P3Zz
SERVER 1:
└──235 Authentication succeeded
CLIENT 1:
└──MAIL FROM: SERVER 1:
└──501 Error { [SenderError: Mail from command failed - 501 name: 'SenderError',
data: '501 stage: 'mail' }
Closing connection to the server

Let me know how do I configure this. I am using this setting as of now:

var smtpTransport = nodemailer.createTransport("SMTP", {
host: "mail.domain.com", // hostname
secureConnection: false, // TLS requires secureConnection to be false
port: 587, // port for secure SMTP
auth: {
user: "[email protected]",
pass: "password"
},
debug:true,
tls: {
rejectUnauthorized: false
}
});

Thanks,
Abhishek Jain

Most helpful comment

Check the from address. Your server does not allow FROM address that uses domain literals. If you did not define the from address, then a default address is generated which might include the domain literal. Make sure that you always use a valid from address when sending emails.

All 5 comments

Check the from address. Your server does not allow FROM address that uses domain literals. If you did not define the from address, then a default address is generated which might include the domain literal. Make sure that you always use a valid from address when sending emails.

Awesome man! Thanks.

Solution for mean Stack: Just define a mail id in config.mailer.from which is not blocked by cPanel.

I have same issue.
Where is the config.mailer.from ?
I changed sender name as Gmail Account name but it doesn't send again.

Updated: Changed unsecure access option in gmail settings and fixed.

@pozitivexx whenever you are sending mails, just make sure you are using right from address.

In below example set mailOptions.from = smtpConfig.auth.user to make sure mail delivers. This is cPanel/Host configuration. Contact hosting partner for more details.

// setup e-mail data with unicode symbols
var mailOptions = {
from: '"Fred Foo πŸ‘₯" [email protected]', // sender address
to: '[email protected], [email protected]', // list of receivers
subject: 'Hello βœ”', // Subject line
text: 'Hello world 🐴', // plaintext body
html: 'Hello world 🐴' // html body
};

you will need SSL config to make it perfect,

let transporter = nodemailer.createTransport({
host: 'SOMEDOMAIN.com',
port: 465, // Port
secure: true, // this is true as port is 465
auth: {
user: '[email protected]',
pass: 'password'
}
});

it's work for me..without any issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mohammedSlimani picture mohammedSlimani  Β·  4Comments

zbisj picture zbisj  Β·  3Comments

thanhthang20 picture thanhthang20  Β·  4Comments

ghost picture ghost  Β·  3Comments

anonprophet picture anonprophet  Β·  3Comments