I'm trying to get my hands dirty with Nodemailer and I am getting the above error message. If I set up my email address and password as plain text then the app works fine, obviously I would rather not do that as I will be pushing to Github, so I have set them up as environment variables as below, unfortunately this leads to the above error message.
I have set up my Gmail account to allow less secure apps.
I have also tried to create a secret.js file with the data in, imported it into app.js and added it to my .gitignore, the issue there is when I try to deploy to Heroku, I guess Heroku has to have access to that file to run the script so it crashes.
let transporter = nodemailer.createTransport({
service: 'gmail',
secure: false,
port: 25, // true for 465, false for other ports
auth: {
user: process.env.EMAIL, // generated ethereal user
pass: process.env.PASSWORD // generated ethereal password
},
tls: {
rejectUnauthorized: false
}
});
I have set my environment variables thusly and none of them work:-
set EMAIL=email@email.com
set EMAIL='email@email.com'
set EMAIL="email@email.com"
I've also used single quotes with ${} hoping this might help, but nope. Completely baffled.