Nodemailer using gmail, Cannot create property 'mailer' on string 'SMTP'

The nodemailer has been reworked, so old code structure could throw such error. Try use the following structure:

var xoauth2 = require('xoauth2');


smtpTrans = nodemailer.createTransport({
  service: 'Gmail', 
  auth: {
    xoauth2: xoauth2.createXOAuth2Generator({
        user: '[email protected]',
        //and other stuff

Please, check official resource for more details:

https://community.nodemailer.com/2-0-0-beta/using-oauth2/


I had similar problem. 'nodemailer-smtp-transport' module solved it

var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
var transport = nodemailer.createTransport(smtpTransport({
    service: 'Gmail',
    auth:{
        xoauth2: xoauth2.createXOAuth2Generator({
            user: '[email protected]',
   //and other stuff

install nodemailer-smtp-transport by 'npm install nodemailer-smtp-transport'


The current problem Today for help is the change of information faster, and Alexander was good when he said "nodemailer is reworked";

i use this easy line to define the transporter:

    var smtpTransport = nodemailer.createTransport("smtps://youruser%40gmail.com:"+encodeURIComponent('yourpass#123') + "@smtp.gmail.com:465"); 

i got it from here https://community.nodemailer.com/