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

nodemailer使用

Prerequisite:

先决条件:

  1. How to send emails using Nodemailer | Node.js

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

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

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

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

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

Code:

码:

// load the node mailer module
var nodemailer = require('nodemailer');    
//configure the transporter
var transporter = nodemailer.createTransport({    
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'your gmail password'
}
});
//email  options
var mailOptions = {
from: '[email protected]',
to: '[email protected]',
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作为传输者,您还可以启用安全性较低的应用访问设置。

Nodemailer 1

Sending email requires internet connection.

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

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

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

Nodemailer 2
Nodemailer 3

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

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

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

nodemailer使用

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/542740.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

angularjs 元素重复指定次数_[LeetCode] 442. 数组中重复的数据

[LeetCode] 442. 数组中重复的数据题目链接&#xff1a; https://leetcode-cn.com/problems/find-all-duplicates-in-an-array难度&#xff1a;中等通过率&#xff1a;61.5%题目描述:给定一个整数数组 a&#xff0c;其中1 ≤ a[i] ≤ n &#xff08; n 为数组长度&#xff09;,…

docker 安装mysql 实战文档_docker 安装mysql

PassJava (佳必过) 项目全套学习教程连载中&#xff0c;关注公众号第一时间获取。docker 安装mysql1.下载镜像sudo docker pull mysql:5.7ubuntuVM-0-13-ubuntu:~$ sudo docker pull mysql:5.75.7: Pulling from library/mysqlc499e6d256d6: Pull complete22c4cdf4ea75: Pull c…

python 补前导零_Python正则表达式| 程序从IP地址中删除前导零

python 补前导零Given an IP address as input, write a Python program to remove leading zeros from it. 给定一个IP地址作为输入&#xff0c;编写一个Python程序以从中删除前导零。 Examples: 例子&#xff1a; Input: 216.08.094.196Output: 216.8.94.196Input: 216.08…

眼球追踪

眼球追踪类似于头部追踪&#xff0c;但是图像的呈现取决于使用者眼睛所看的方向。例如&#xff0c;人们可以用“眼神”完成一种镭射枪的瞄准。眼球追踪技术很受VR专家们密切关注。Oculus创始人帕尔默拉奇就曾称其为“VR的心脏”。对于人眼位置的检测&#xff0c;能够为当前所处…

mysql 创建分区表_Mysql分区表及自动创建分区Partition

Range分区表建表语句如下&#xff0c;其中分区键必须和id构成主键和唯一键CREATE TABLE test1 (id char(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT ‘自增主键(guid)‘,create_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘创建时间‘,partition_key …

python下载文件暂停恢复_Python关于Threading暂停恢复解决办法

我们都知道python中可以是threading模块实现多线程, 但是模块并没有提供暂停, 恢复和停止线程的方法, 一旦线程对象调用start方法后, 只能等到对应的方法函数运行完毕. 也就是说一旦start后, 线程就属于失控状态. 不过, 我们可以自己实现这些. 一般的方法就是循环地判断一个标志…

信息系统状态过程图_过程状态图中使用的重要术语| 操作系统

信息系统状态过程图1)上下文切换 (1) Context Switching) Whenever a process is transferred within the system, it moves within different states. These states are known as the process states. When a process goes from one state to another state inside the system…

mysql 吧库下的表名都加_mysql数据库表名大小写问题

mysql数据库表名大小写问题mysql数据库linux版本表名、字段名默认大小写敏感&#xff0c;即区分大小写。查看mysql有关大小写参数&#xff1a;lower_case_file_system是一个只读参数&#xff0c;无法被修改&#xff0c;这个参数是用来告诉你在当前的系统平台(linux\windows等)下…

rgb 灰色_金属+RGB+无线,我要买爆这款海盗船VIRTUOSO鉴赏家游戏耳机

海盗船最近新出的旗舰耳机&#xff0c;VIRTUOSO RGB Wireless SE&#xff0c;中文名叫鉴赏家。耳机一改往日欧美电竞风&#xff0c;改走金属质感高大上简约风&#xff0c;不过讲真&#xff0c;这颜值我吃起来很香。考虑文章过长&#xff0c;我先概括一下入手理由&#xff0c;具…

python 基类 派生类_在Python中具有两个子(派生)类的继承示例

python 基类 派生类In this program, we have a parent class named Details and two child classes named Employee and Doctor, we are inheritance the class Details on the classes Employee and Doctor. And, finally creating two objects of Employee and Doctor class…

连接postgresql

# psycopg2enginecreate_engine(postgresqlpsycopg2://scott:tigerlocalhost/mydatabase)#python 连接postgresql使用psycopg2作为默认的DBAPIThe first time a method like Engine.execute()orEngine.connect()is called, the Engine establishes a real DBAPI connection to …

n的阶乘程序python_Python程序对N阶乘的尾随零进行计数

n的阶乘程序pythonFormula used: 使用的公式&#xff1a; Trailing 0s in N! Count of 5s in prime factors of n! floor(n/5) floor(n/25) floor(n/125) ....Example: 例&#xff1a; Input: N 23Output: 4Factorial of 23 is 25852016738884976640000 which has four …

c mysql使用场景_Mysql 场景

1个SQL题&#xff0c;1个场景题&#xff0c;会有点难度&#xff01;SQL题该SQL题大量涉及到row_number&#xff0c;case when&#xff0c;group by等高级用法&#xff0c;有一定的实用价值&#xff0c;总结出来&#xff0c;供日后参考Question.1&#xff1a;分组汇总给定筛选条…

以己为壑

2019独角兽企业重金招聘Python工程师标准>>> 今天把软件工程里面关于面向对象的设计学完了,使我对面向对象OOA和OOD的思想有了进一步的认识,各科知识千沟万壑,犬牙交错,的确是这样,能蒙住自己眼的永远是你自己,而不是这个世界,因为美就在那里;裹住自己双足的的永远是…

macos安装vscode_如何使用VSCode进行PostgreSQL开发及调试

Visual Studio Code (VSCode)是一个轻量级但功能强大的源代码编辑器&#xff0c;可在桌面上运行&#xff0c;适用于Windows&#xff0c;macOS和Linux。 它内置了对JavaScript&#xff0c;TypeScript和Node.js的支持&#xff0c;并具有丰富的其他语言(如C&#xff0c;C&#xff…

最小生成树 kruskal_使用Kruskal算法求解Java最小生成树问题

最小生成树 kruskalIn Electronic Circuit we often required less wiring to connect pins together. We can model this wiring problem with a connected, undirected graph G(V, E), where V is the set of pins, E is the set of possible interconnections between pair …

mysql数据库面试题 软件测试_软件测试数据库面试题一

前提本次分享只局限于 sql server 和 mysql 这两种数据库&#xff0c;其他数据库暂不总结正文1. 对查询的字段进行去重(distinct)用法注意&#xff1a;1. distinct【查询字段】&#xff0c;必须放在要查询字段的开头&#xff0c;即放在第一个参数&#xff1b;2. 只能在SELECT 语…

python数码时钟代码_python时钟的实现

from time importsleepimporttimeimportosclassClock(object):"""数字时钟""" def __init__(self, hour0, minute0, second0):"""初始化方法 :param hour: 时 :param minute: 分 :param second: 秒"""self._hourh…

PHP页面跳转

本文转载自&#xff1a;http://blog.sina.com.cn/s/blog_9a06890901014ol1.html PHP页面跳转一、header()函数 header函数中Location类型的标头是一种特殊的header调用&#xff0c;常用来实现页面跳转 注意&#xff1a;1、location和“:”号间不能有空格&#xff0c;否则不会跳…

如何打印出给定尺寸的方格_打印给定号码的表格| 8086微处理器

如何打印出给定尺寸的方格Problem statement: 问题陈述&#xff1a; Write an assembly language program in 8086 to print the table of a given integer. 在8086中编写汇编语言程序以打印给定整数的表。 Assumptions: Suppose the inputted number is at memory location …