Grogu
Grogu

Reputation: 2505

535 Authentication Failed - Twilio SendGrid SMTP Relay NodeJS

I have a verified mail with Twilio SendGrid. I'm following the SMTP Relay stat up guide here. I can't get it to send email using their SMTP Relay and NodeMailer. I need to know what I'm doing wrong?

In the example, they create an API Key and a password for you.

I'm using nodemailer here :

//smtp
smtpTransport = nodemailer.createTransport(smtpTransport({
host: "smtp.sendgrid.net",
//secure: true,
port: 587,
auth: {
user: sendgrid_api_key, // generated ethereal user
pass: sendgrid_pass, // generated ethereal password
},
}));

When I run this I get error in the console :

Error: Invalid login: 535 Authentication failed: Bad username / password at SMTPConnection._formatError

Upvotes: 0

Views: 1038

Answers (1)

philnash
philnash

Reputation: 73075

When using SMTP to send emails with SendGrid, the username you should use is the string apikey. Then the password should be your actual API key that has permission to send emails.

Upvotes: 0

Related Questions