Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodemailer "Error: Missing credentials for "PLAIN" After Gmail API Credentials

Everything is working fine when locally hosted, but when accessing my backend hosted on Heroku I get the error, "Error: Missing credentials for "PLAIN". This isn't the first time for me either, I went through this whole troubleshooting struggle. Even after trying different mail services to see if the error would go away, nothing worked. I even got the Gmail API OAuth codes but this error is still showing up on Heroku. Any thoughts?

let transporter = nodemailer.createTransport({
        host: "smtp.gmail.com",
        service: Gmail,
        port: 587,
        secure: false, // true for 465, false for other ports
        auth: {
            user: process.env.EMAIL,
            pass: process.env.PASS,
            clientId: process.env.CLIENTID,
            clientSecret: process.env.CLIENTSECRET,
            refreshToken: process.env.REFRESH
        },
        tls: {
            rejectUnauthorized: false
        }
    });

Heroku: Console Image for Error Log

like image 209
coddingtonjoel Avatar asked Jul 09 '26 02:07

coddingtonjoel


1 Answers

kindly comment out host: "smtp.gmail.com" as service line below it is sufficient. You may out your password in single quotes in front of pass like this for a quick fix: pass: 'yourpassword', of course that's not the best way to do it, but it may solve the issue temporarily until you find a better way to do it.

like image 90
zuak Avatar answered Jul 10 '26 15:07

zuak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!