使用Mandrill作为SMTP提供程序时的身份验证错误

Bur*_*han 4 email node.js nodemailer

我试图在我的nodejs应用程序中使用nodemailer发送电子邮件.我尝试使用gmail发送,一切正常但是当我使用Mandrill作为我的SMTP提供程序时,我收到了身份验证错误.

这是我的代码:

var smtpTransport = nodemailer.createTransport("SMTP",{
    service: "Mandrill",
    auth: {
        user: "username@mydomain.com",
        pass: "*****"
    }
});

module.exports.sendEmail = function(to, subject, body, callback){
    smtpTransport.sendMail({
        from: "username@mydomain.com",
        to: to,
        subject: subject,
        html: body
    }, function(error, response){
        if(error){
            console.log(error); callback(error, response);
        }else{
            callback(null, response);
        }
    });
};

};
Run Code Online (Sandbox Code Playgroud)

这就是我得到的错误

{ [AuthError: Invalid login - 435 4.7.8 Error: authentication failed:]
    name: 'AuthError',
        data: '435 4.7.8 Error: authentication failed:',
    stage: 'auth' }
Run Code Online (Sandbox Code Playgroud)

小智 7

我遇到了类似的问题.在我的情况下,身份验证错误是因为mandrill不接受您的mandrill帐户密码作为smtp身份验证密码,而是您可以在仪表板上生成的api密钥.用户名与您的帐户用户名相同.误解的产生可能是因为在mandrill的主页上有例子,但是在SMTP和API凭证页面(登录后)明确提到smtp密码是api密钥.

希望这会有所帮助.

  • 对.只是详细说明代码如下:`var transport = nodemailer.createTransport('SMTP',{service:'Mandrill',auth:{user:'admin@mixmax.com',pass:'1NAkHCOllEE4*****' }};` (2认同)