2017-04-13 28 views
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); 
      } 
     }); 

我想要認證的發件人地址不同嗎? 假設我使用[email protected]驗證了數據,但是我想將郵件從[email protected]發送到[email protected]。 如何在節點郵件中做到這一點?如何更改發件人姓名不同形式的認證電子郵件?

// Using send mail npm module 

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

但在跨度箱來的郵件,我們正在發送中不會在發件人郵件地址的發送的郵件顯示郵件?

我希望我能闡述我的問題

+0

可能的重複[您如何確保以編程方式發送的電子郵件不會自動標記爲垃圾郵件?](http://stackoverflow.com/questions/371/how-do-you-make-sure-email-you - 發送 - 編程 - 是 - 不自動標記) – Gntem

回答

0

我不認爲你可以。 Gmail不允許更改發件人地址。

但是,您可以尋找其他服務,如郵戳,sendgrid或創建自己的smtp服務器。

相關問題