nodejs发送邮件
这里我主要使用的是 nodemailer 这个插件
第一步 下载依赖
cnpm install nodemailer --save
第二步 建立email.js
'use strict';
const nodemailer = require('nodemailer');
let transporter = nodemailer.createTransport({
// host: 'smtp.ethereal.email',
service: 'qq', // 使用了内置传输发送邮件 查看支持列表:https://nodemailer.com/smtp/well-known/
port: 465, // SMTP 端口
secureConnection: true, // 使用了 SSL
auth: {
user: 'xxxxxx@qq.com',//你的邮箱
// 这里密码不是qq密码,是你设置的smtp授权码
pass: 'qq的授权码',
}
});
let mailOptions = {
from: '"火星黑洞" <@qq.com>', // sender address
to: '156093340@qq.com', // list of receivers
subject: 'Hello', // Subject line
// 发送text或者html格式
// text: 'Hello 我是火星黑洞', // plain text body
html: '<b>Hello 我是火星黑洞</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message sent: %s', info.messageId);
// Message sent: <04ec7731-cc68-1ef6-303c-61b0f796b78f@qq.com>
});
第三步,执行 node email.js,即可发送成功~

注:可以前往 https://jingyan.baidu.com/article/fedf0737af2b4035ac8977ea.html 去查看如何设置授权码
nodejs发送邮件的更多相关文章
- nodejs 发送邮件(阿里云)
1.下载 模块 2. 编辑文件 var nodemailer = require('nodemailer'); var sendEmail = function(emailinfo,callbac ...
- Nodejs 发送邮件 激活邮箱
1. 安装nodemailer npm install nodemailer 项目中引入nodemailer var nodemailer = require('nodemailer'); 2.QQ邮 ...
- nodejs——发送邮件(带附件)
用到的包是 nodemailer,简单,有效. 1.auth 中的 pass,是指“邮箱第三方登录授权码”,如何获取授权码,以QQ邮箱为例,请点击:http://jingyan.baidu.com/a ...
- Nodejs 发送邮件
var nodemailer = require("nodemailer");var mailTitle='http://bemupa.forumieren.com:Best Mu ...
- 关于nodejs的几个干货(读中文文件编码问题/发送邮件/定时任务)
关于nodejs读取中文文件真是折腾了不少时间,网上各种方案,最后没有一个适用我,好在解决了. 下面的三个知识点都是从项目中抽出的,要单独运行脚本的话需要用全局模式来安装模块,比如安装中文转换模块(后 ...
- nodejs实现邮件发送
需要安装的node模块 nodemailer 新建项目目录 mail-test 进入这个项目里使用终端初始化package.json(npm init) 安装express和nodemailer并保存 ...
- node nodemailer
需求:通过nodejs发送邮件 一般都是用nodemailer这个模块.目前有0.7和1.0两个版本,网上的很多教程和代码,大都是按照0.7写的,自己做的时候需要注意看README.md 支持的ser ...
- 利用github给国外文件下载加速
前言 作为一名程序员,经常需要下载一些编程相关的环境,而国内的网络环境大家都知道,有的文件用浏览器是下载不动的,于是我有了利用github下载文件的想法. 我的demo项目地址:https://git ...
- Nodejs之发送邮件nodemailer
nodejs邮件模块nodemailer的使用说明 1.介绍 nodemailer是node的一个发送邮件的组件,其功能相当强大,普通邮件,传送附件,邮件加密等等都能实现,而且操作也十分方便. nod ...
随机推荐
- [No0000106]配置PLSQL,提升工作效率
界面模板的配置: 方便用户快速点击需要的功能.如打开SQL Window 1.打开customize,用户自定义Toolbars对话框. 2.在Commands命令标签页,选中要添加的命令,拖动到工具 ...
- 关于使用 Spring 发送简单邮件
这是通过Spring 框架内置的功能完成简单邮件发送的测试用例. 导入相关的 jar 包. Spring 邮件抽象层的主要包为 org.springframework.mail. 它包括了发送电子邮件 ...
- 分布式事务之TCC服务设计和实现注意事项
分布式事务之TCC服务设计和实现注意事项-云栖社区-阿里云 https://yq.aliyun.com/articles/609854 分布式事务之TCC事务丶一个站在Java后端设计之路的男青年个人 ...
- #include<stdio.h> #include "stdio.h"
https://baike.baidu.com/item/#include <stdio.h> #include <stdio.h> 编辑 #include<stdio. ...
- [daily][centos][sudo] sudo 报错
有时候, 比如在CentOS 6上. sudo 会报如下错误: sudo: must be setuid root 这是因为, sudo 命令, 没有SUID, [root@T209 ~]# ll / ...
- [daily][dpdk] 内核模块(网卡驱动)无法卸载
由于程序的异常退出, 内核的引用计数没有被清除(我猜的). 所以驱动不能被卸载掉, 强制也不行. 如下: [root@localhost ~]# insmod /opt/scorpion/KingKo ...
- [hardware][intel] intel全系列网卡调研
除了公司用,我自己还要买一块家用. 但是在这一切开始之前,还需要搞清楚PCIE到底咋回事. 一, 总线 https://zh.wikipedia.org/wiki/%E6%80%BB%E7%BA%BF ...
- LeetCode 965 Univalued Binary Tree 解题报告
题目要求 A binary tree is univalued if every node in the tree has the same value. Return true if and onl ...
- 提取json响应结果值_后置处理器JSON Extractor
Json响应格式 json串中{}表示对象,[]表示数组 JSON Extractor使用json path表达式匹配,可以一次取多个变量值. $表示响应的根对象. 取子对象或对象的属性用. 取数组里 ...
- mvn install package区别
package是把jar打到本项目的target下,而install时把target下的jar安装到本地仓库,供其他项目使用