node.js nodemailer gmail error

后端 未结 2 366
一整个雨季
一整个雨季 2020-12-31 09:30

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

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

h         


        
相关标签:
2条回答
  • 2020-12-31 10:04

    it's works with me after using none-secure port

    var transporter = nodemailer.createTransport({
      host: 'smtp.gmail.com',
      port: 587,
      secure: false, // secure:true for port 465, secure:false for port 587
      auth: {
        user: 'xxxx@gmail.com',
        pass: 'xxxx'
      }
    });
    
    0 讨论(0)
  • 2020-12-31 10:06

    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: 'myemail@gmail.com', // 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

    0 讨论(0)
提交回复
热议问题