Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authentication error nodemailer when using Mandrill as SMTP provider

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' }
like image 207
Burhan Avatar asked Mar 19 '23 09:03

Burhan


1 Answers

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.

like image 96
user3722054 Avatar answered Apr 06 '23 06:04

user3722054