0
 var nodemailer = require('nodemailer');

// Not the movie transporter!
  var transporter = nodemailer.createTransport({
      service: 'gmail',
      auth: {
          user: '*****@gmail.com', // Your email id
          pass: '*******' // Your password
      }
  });




var mailOptions = {
           from: varfrom_name, // sender address
           to: varto, // list of receivers
           subject: varsubject, // Subject line
           text: vartext, // plaintext body
           html: varhtml // html body
       };


       console.log(mailOptions);

       // send mail with defined transport object
        transporter.sendMail(mailOptions, function (error, info) {
           if (error) {
               return console.log(error);
           }else{
             return console.log(info);
           }
       });

I want different sender address from the authenticated one ? Suppose I authenticated data with abc@gmail.com, but I want to send the mail from xyz@gmail.com to def@gmail.com. How to do that in node-mailer ?

// Using send mail npm module

var sendmail = require('sendmail')({silent: true})
      sendmail({
        from: ' xyz@gmail.com',
        to: 'def@gmail.comh',
        subject: 'MailComposer sendmail',
        html: 'Mail of test sendmail ',
        attachments: [
        ]
      }, function (err, reply) {
        console.log(err && err.stack)
        console.dir(reply)
      })

But the mails coming in the span box and the mails that we are sending is won't showing in the sent mail of sender mail address ?

I hope i will able to elaborate my question

VIKAS KOHLI
  • 8,164
  • 4
  • 50
  • 61
  • Possible duplicate of [How do you make sure email you send programmatically is not automatically marked as spam?](http://stackoverflow.com/questions/371/how-do-you-make-sure-email-you-send-programmatically-is-not-automatically-marked) – Gntem Apr 13 '17 at 07:13

1 Answers1

0

I don't think you can. Gmail does not allow the change of the sender address.

However, you can look for another service, like postmark, sendgrid, or create your own smtp server.

Ivan Dzhurov
  • 187
  • 6