Thursday 15 July 2010

Sending email via Node.js using nodemailer is not working -



Sending email via Node.js using nodemailer is not working -

i've set basic nodejs server (using nodemailer module) locally (http://localhost:8080) can test whether server can send out emails.

if understand smtp alternative correctly (please right me if i'm wrong), can either seek send out email server someone's email business relationship directly, or can send email, still using node.js, via actual email account (in case personal gmail account), i.e using smtp. alternative requires me login acount remotely via nodejs.

so in server below i'm trying utilize nodejs send email personal email business relationship personal email account.

here's simple server :

var nodemailer = require('nodemailer'); var transporter = nodemailer.createtransport("smtp", { service: 'gmail', auth: { user: '*my personal gmail address*', pass: '*my personal gmail password*' } }); var http = require('http'); var httpserver = http.createserver(function (request, response) { transporter.sendmail({ from: '*my personal gmail address*', to: '*my personal gmail address*', subject: 'hello world!', text: 'hello world!' }); }).listen(8080);

however, it's not working. got email google saying :

google account: sign-in effort blocked if can switch app made google such gmail access business relationship (recommended) or alter settings @ https://www.google.com/settings/security/lesssecureapps business relationship no longer protected modern security standards.

i couldn't find solution above problem on nodemailer github page. have solution/suggestion ?

thanks! :-)

the reply in message google.

go : https://www.google.com/settings/security/lesssecureapps

set access less secure apps setting enable

for sec part of problem, , in response

i'm next steps nodemailer github page there no errors in code

i refer nodemailer github page, , piece of code :

var transporter = nodemailer.createtransport({ service: 'gmail', auth: { user: 'gmail.user@gmail.com', pass: 'userpass' } });

it differs code, in fact have : nodemailer.createtransport("smtp". remove smtp parameter , works (just tested). also, why encapsulating in http server? next works :

var nodemailer = require('nodemailer'); var transporter = nodemailer.createtransport({ service: 'gmail', auth: { user: 'xxx', pass: 'xxx' } }); console.log('created'); transporter.sendmail({ from: 'xxx@gmail.com', to: 'xxx@gmail.com', subject: 'hello world!', text: 'hello world!' });

node.js email smtp nodemailer

No comments:

Post a Comment