I am trying to send email by using nodemailer in my nodejs application. I tried to send with gmail and everything was ok but when I use Mandrill as my SMTP provider I got an Authentication error.
here is my code:
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Mandrill",
auth: {
user: "[email protected]",
pass: "*****"
}
});
module.exports.sendEmail = function(to, subject, body, callback){
smtpTransport.sendMail({
from: "[email protected]",
to: to,
subject: subject,
html: body
}, function(error, response){
if(error){
console.log(error); callback(error, response);
}else{
callback(null, response);
}
});
};
};
and thats the error I got
{ [AuthError: Invalid login - 435 4.7.8 Error: authentication failed:]
name: 'AuthError',
data: '435 4.7.8 Error: authentication failed:',
stage: 'auth' }
I encountered a similar problem. In my case the authentication error was because mandrill does not accept your mandrill account password as the smtp authentication password, rather an api key which you can generate on your dashboard. The username is the same as you account username. The misconception arises probably because of the examples on mandrill's home-page, but it is explicitly mentioned under the SMTP & API credentials page (once you login) that smtp password is an api key.
Hopefully this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With