I'm using nodemailer to try to send an email to myself via commandline:
var nodemailer = require('nodemailer');
// config
var smtpConfig = {
host: 'smtp.myhost.com',
port: 465,
secure: false, // dont use SSL
tls: {rejectUnauthorized: false}
};
// create reusable transporter object using the default SMTP transport
var transporter = nodemailer.createTransport(smtpConfig);
// setup e-mail data with unicode symbols
var mailOptions = {
from: '"Fred Foo " <foo@blurdybloop.com>', // sender address
to: 'person@gmail.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world ', // plaintext body
html: '<b>Hello world </b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
When I try to run this code I get the following error:
Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at\n535 5.7.8 https://support.google.com/mail/answer/14257
The link takes you to a page that tells you to register your app inside Google Console. But this is not what I'm trying to do.
There are loads of email clients that can send an email to a gmail inbox without having to sign into that email account. This is what I'm trying to do. I'm trying to turn my terminal into an smtp client that can send a mail message to any inbox. This shouldn't require extensive authentication. How do I do this?
NOTE
Just to provide some perspective, I'm trying to replicate in node whats possible with the unix sendmail
command:
sendmail person@gmail.com < testemail.txt
How can I do this using nodemailer?