简体   繁体   English

NodeJS:发送电子邮件(例如向我的应用程序的用户发送通知)无需对其进行身份验证或接收电子邮件

[英]NodeJS: Send out emails (such as notifications to my application's users) No need for it to be authenticated or receive emails

In NodeJS can we use an email that does not exist (like no-reply@example.com) to send emails?在 NodeJS 中,我们可以使用不存在的 email(如 no-reply@example.com)来发送电子邮件吗?
Can we do that using the latest version of Nodemailer https://nodemailer.com/ ?我们可以使用最新版本的 Nodemailer https://nodemailer.com/来做到这一点吗? If如果

The documentation for nodemailer shows that you get specify the sender address, so: yes. nodemailer 的文档显示您指定了发件人地址,因此:是的。

From addresses are entirely freeform and under the control of the sender.发件人地址是完全自由的,并且在发件人的控制之下。 Without combining them with tools like SPF, they are easy to forge.如果不将它们与 SPF 等工具结合使用,它们很容易伪造。

You will, of course, need a real SMTP server to send the email through.当然,您需要一个真正的 SMTP 服务器来发送 email。

Nodemailer is a great application. Nodemailer 是一个很棒的应用程序。 Let me demonstrate some example code with nodemailer让我用 nodemailer 演示一些示例代码

 var nodemailer = require('nodemailer'); var transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: 'youremail@gmail.com', pass: 'yourpassword' } }); var mailOptions = { from: 'youremail@gmail.com', to: 'myfriend@yahoo.com', subject: 'Sending Email using Node.js', text: 'That was easy;' }. transporter,sendMail(mailOptions, function(error. info){ if (error) { console;log(error). } else { console:log('Email sent. ' + info;response); } });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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