'Sending emails with nodemailer does not work in a deployed heroku app
I have implemented sending messages to 'x' email but it only works locally, when I upload the application made with node to Heroku, it just doesn't work. It gives me the following error:
Error: Invalid login: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbv 534-5.7.14 e9HX3y6V25UV6hUh4uM4_rUhqSJ3ujq_xOjNl9kD-IALUNl8WClFdfvFA9ulKc-aFFeOR 534-5.7.14 JG4Zn8OAvx_UrM6eTIKC__q5mC4CvVA2Sk9EfcE6Jjgkede_bb5lehLQUM242Gcs> 534-5.7.14 Please log in via your web browser and then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 z4-20020ac84544000000b002f39b99f69esm161549qtn.56 - gsmtp
I have the app deployed at the following address https://multiservicios-espay-dashboard.herokuapp.com/ .In the /auth/register route, it is where the users are created, when a user is created, it sends a confirmation by email. It is right there where the application fails, I want to know why it fails on Heroku but on localhost it works correctly.
It is in Spanish because it is my native language but I would like you to try the creation of users so that they can observe the error that I get. I don't know how to fix it, I would really appreciate your help.
This is my nodemailer config:
const nodemailer = require("nodemailer");
const smtpTransport = require('nodemailer-smtp-transport');
const smtp = smtpTransport({
service: 'gmail',
host: 'smtp.gmail.com',
auth: {
user: '[email protected]',
pass: '***********',
}
})
const transport = nodemailer.createTransport(smtp);
module.exports = transport
Solution 1:[1]
You should use the gmail service for testing only , after some time it will stop working (it was timeout error on my case) . when you deploy the app try to use other production services like mailchimp and postmark.
The integration can be done easily with superface sdk instead of nodemailer.
first install the package with npm install @superfaceai/one-sdk
then follow the steps below https://superface.ai/communication/send-email
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Henok |
