第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > nodemailer使用_如何使用Nodemailer使用HTML作为内容发送电子邮件 Node.js

nodemailer使用_如何使用Nodemailer使用HTML作为内容发送电子邮件 Node.js

时间:2018-10-02 08:28:38

相关推荐

nodemailer使用_如何使用Nodemailer使用HTML作为内容发送电子邮件 Node.js

nodemailer使用

Prerequisite:

先决条件:

How to send emails using Nodemailer | Node.js

如何使用Nodemailer发送电子邮件。 Node.js

How to send emails with attachments using Nodemailer | Node.js

如何使用Nodemailer发送带有附件的电子邮件。 Node.js

This time around, we will seehow to compose or build/format our email body using HTML?

这次,我们将看到如何使用HTML编写或构建/格式化电子邮件正文?

Code:

码:

// load the node mailer modulevar nodemailer = require('nodemailer'); //configure the transportervar transporter = nodemailer.createTransport({service: 'gmail',auth: {user: '[emailprotected]',pass: 'your gmail password'}});//email optionsvar mailOptions = {from: '[emailprotected]',to: '[emailprotected]',subject: 'Sending Email using Node.js',html: '<h1> Node JS </h1> <br> <h5> Hello World</h5>'};transporter.sendMail(mailOptions, function(error, info){if (error) {console.log(error);} else {console.log('Email sent');}});

Note:You can use the same format and send as many attachments as possible. Make sure the closing curly bracket of each attachment is separated by a comma sign (,).

注意:您可以使用相同的格式并发送尽可能多的附件。 确保每个附件的大括号用逗号(,)分隔。

Finally, start your node app and if sending is successful, the phrase ‘email sent' will be printed out on the console or terminal.

最后,启动您的节点应用程序,如果发送成功,则将在控制台或终端上打印出短语“已发送电子邮件”。

Check you're the email's inbox.

检查您是否是电子邮件的收件箱。

Using Gmail as your transporter, you can also enable the less secure app access setting.

使用Gmail作为传输者,您还可以启用安全性较低的应用访问设置。

Sending email requires internet connection.

发送电子邮件需要互联网连接。

Do not fear about your password security. It's a tested and secured module used by many since .

不要担心您的密码安全性。 自以来,它已被许多人使用并经过测试和保护。

Thanks for coding with me! See you @ the next article. Feel free to drop a comment or question.

感谢您与我编码! 下次见。 随意发表评论或问题。

翻译自: /node-js/how-to-send-emails-with-nodemailer-using-html-as-content-node-js.aspx

nodemailer使用

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。