简体   繁体   中英

Nodemailer send an anonymous email

I'm using NodeMailer . It is working well but I want to send an anonymous email (with a fake name and email adress) it doesn't as it should be. Here is my code :

let transporter = nodemailer.createTransport({
                host: 'smtp.gmail.com', 
                port: 587,
                secure: false,
                auth: {
                   user: 'myrealAdress@gmail.com', 
                   pass: 'mypass' 
                }
            });
            var textMail = emailContent
            fs.readFile("./"+myCSV.name+".csv", function (err, data) {
                    transporter.sendMail({       
                        from: 'JourneyBuilder <noreply.journeybuilder@gmail.com>',
                        to: userToSendMail,
                        subject: subjectMail,
                        text: textMail,
                        attachments: [{'filename': myCSV.name+'.csv', 'content': data}]
            }), function(err, success) {
                    if (err) {
                        console.log("ERROR SEND : "+err);
                    }
            }
});

When I send this I receive the email well, the name is ' Journey Builder ' but the email is still mine (the transporter's one: myrealAdress@gmail.com) where it should be 'noreply.journeybuilder@gmail.com' . Thanks to help me if you have any idea on this!

As far as i know (by the docs) it's not possible to hide your Email completly when sending a mail via nodemailer . you can either use a own mailserver or just set the replyaddress to the noreply address like this:

transporter.sendMail({       
  from: 'JourneyBuilder <noreply.journeybuilder@gmail.com>',
  replyTo: 'noreply.journeybuilder@gmail.com'
  ...

means people would reply to this address and not to the one you sent the mail with

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM