Emails sent from SMTP server hosted on hostmonster using nodemailer are not delivering to the recipients

1.2k Views Asked by At

Our SMTP server is hosted on hostmonster. We are using nodemailer to send emails from our app to the users. The problem I am facing is that, I am getting 250 OK response from the SMTP server but the emails don't get delivered to the users. I am using the exact email configurations provided by the hostmonster. Our nodemailer configurations are:

var mailTransporter = nodemailer.createTransport({
host: "mail.domain.com",
port: 456,
secure: true,
auth: {
  user: "[email protected]",
  pass: "password"
},
tls: {
        rejectUnauthorized: false,
     },
});

And the response I get:

{ accepted: [ '[email protected]' ],
  rejected: [],
  envelopeTime: 899,
  messageTime: 315,
  messageSize: 3464,
  response: '250 OK id="someid"',
  envelope:
   { from: '[email protected]',
     to: [ '[email protected]' ] },
  messageId: '<[email protected]>' }

I expect the email to get delivered to the users (recipients) but it doesn't get delivered. Could anyone of you please verify my nodemailer configurations? Is there any issue with my nodemailer configurations? or Could there be any issue on the hostmonster side?

1

There are 1 best solutions below

0
Abdul Rasheed On BEST ANSWER

Turned out, I need to add "name" option to the createTransport() configuration. The name should be the domain i.e. "www.domain.com".

var mailTransporter = nodemailer.createTransport({
name: "www.domain.com",
host: "mail.domain.com",
port: 456,
secure: true,
auth: {
  user: "[email protected]",
  pass: "password"
},
tls: {
        rejectUnauthorized: false,
     },
});

Reference: https://github.com/nodemailer/nodemailer/issues/677