Nodemailer send emails using original user account instead of alias

喜你入骨 提交于 2019-12-10 20:09:11

问题


I have a problem with nodemailer where the user receive the email with sent from my google account which used to authenticate gmail instead of the alias used in mail options.

Below is my code:

var smtpTransport = nodemailer.createTransport({
    service: config.mailer.options.service,
    auth: {
        user: "xxxx@gmail.com",
        pass: "password"
    }
});


var mailOptions = {
       to: user.email,
       from: 'Test Email <aaa@aaa.com>',
       subject: subject,
       html: emailHTML
};

smtpTransport.sendMail(mailOptions); Now when the user receive an email the email mentions that

from: Test Email xxxx@gmail.com

Instead of showing

from: Test Email aaa@aaa.com

Any help please


回答1:


you also need to configure the alias in your gmail account. I faced the same issue but after configuring alias in gmail it worked. check this link to configure https://support.google.com/mail/answer/22370?hl=en




回答2:


Now, with Gmail, you can use aliases as your main account. Just go into Gmail settings under account and select default.



来源:https://stackoverflow.com/questions/34628729/nodemailer-send-emails-using-original-user-account-instead-of-alias

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!