Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
81
rated 0 times [  84] [ 3]  / answers: 1 / hits: 21862  / 9 Years ago, mon, september 7, 2015, 12:00:00

Im trying to send a email using node.js - nodemailer module , my whole code looks like



var http=require(http);
var nodemailer=require(nodemailer);

http.createServer(function(req,res){
res.writeHead(200, {Content-Type: text/plain});
var transporter = nodemailer.createTransport('SMTP',{
service: 'gmail',
auth: {
user: '[email protected]', // my mail
pass: 'mypassword'
}
});
var mailOptions = {
from: 'Fred Foo ✔ <[email protected]>', // sender address
to: '[email protected]', // the same mail = want to send it to myself
subject: 'Hello ✔', // Subject line
text: 'Hello world ✔', // plaintext body
html: '<b>Hello world ✔</b>' // html body
};
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);

});
res.end(hllo);
}).listen(4000)


but when i run it , it throws login error , altought my name/pass are correct the whole error looks like this



{ [AuthError: Invalid login - 534-5.7.14 <https://accounts.google.com/ContinueSi
gnIn?sarp=1&scc=1&plt=AKgnsbtWV
534-5.7.14 FHw6FqlXkg3nIQW7AtsO7o0r-4EtD7eTtnrgHeXxeULYqUtHjrnTB9R647mlR7GY9Z4lS
z
534-5.7.14 WuzYYnNwNBjIyrjNzHk-o9sIV_vIsbjgF5HsFPtJl5S0dSf3eyNCX_E8tQ_Z6s4Z1mUe5
i
534-5.7.14 p8Y5YagzdN5RSkjpB1yTu3TfWHSTLisczIZphhLfhlz-v86tAB8MX-4jRqA51hfJYy0ko
F
534-5.7.14 qytMeIbs1kUZEJzPIabmjRi87DIk> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14 Learn more at
534 5.7.14 https://support.google.com/mail/answer/78754 cx1sm17733852wib.0 - gs
mtp]
name: 'AuthError',
data: '534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt
=AKgnsbtWVrn534-5.7.14 FHw6FqlXkg3nIQW7AtsO7o0r-4EtD7eTtnrgHeXxeULYqUtHjrnTB9R
647mlR7GY9Z4lSzr534-5.7.14 WuzYYnNwNBjIyrjNzHk-o9sIV_vIsbjgF5HsFPtJl5S0dSf3ey
NCX_E8tQ_Z6s4Z1mUe5irn534-5.7.14 p8Y5YagzdN5RSkjpB1yTu3TfWHSTLisczIZphhLfhlz-v
86tAB8MX-4jRqA51hfJYy0koFrn534-5.7.14 qytMeIbs1kUZEJzPIabmjRi87DIk> Please log
in via your web browser andrn534-5.7.14 then try again.rn534-5.7.14 Learn
more atrn534 5.7.14 https://support.google.com/mail/answer/78754 cx1sm1773385
2wib.0 - gsmtp',
stage: 'auth' }


is there something i have to set in my gmail acc to allow this to send email from that or how can i fix it


More From » node.js

 Answers
2

Try installing nodemailer-smtp-transport and then use it inside your createTransport function.



var smtpTransport = require('nodemailer-smtp-transport');

var transport = nodemailer.createTransport(smtpTransport({
service: 'gmail',
auth: {
user: '[email protected]', // my mail
pass: 'mypassword'
}
}));


And try also while in your google account enabling this:
https://www.google.com/settings/security/lesssecureapps



I really think this should be your auth problem


[#65152] Friday, September 4, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
angelicajayleneh

Total Points: 216
Total Questions: 110
Total Answers: 100

Location: Sudan
Member since Tue, Aug 3, 2021
3 Years ago
;