前言

今天,我们给大家开发一个小效果。篇幅比较短,主要给大家展示效果。
实战

首先我们初始化一个Node项目

npm init -y

创建一个app.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: 'xxx@qq.com', // 这里以QQ邮箱为例
pass: 'kzudmlwerknibejc', // 设置的smtp授权码
}
}); let mailOptions = {
from: '"xxx" <xxx@qq.com>', // sender
to: 'xxx@163.com', // receivers
subject: 'Hello', // Subject line
// 发送text或者html格式
// text: 'Hello world?', // plain text body
html: '<b>Hello world?</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>
}); Nodemailer是一个简单易用的Node.js邮件发送组件。 官网地址:https://nodemailer.com GitHub地址:https://github.com/nodemailer/nodemailer

更多内容请见原文,原文转载自:https://blog.csdn.net/weixin_44519496/article/details/119809451

最新文章

  1. ListBox实现拖拽排序功能
  2. CCSprite的使用方法大全
  3. HDU-4418 Time travel 概率DP,高斯消元
  4. MSSTDFMT.dll系统文件(附2种MSSTDFMT.dll 注册方法)-系统增强
  5. three.js 源代码凝视(十六)Math/Frustum.js
  6. PPT素才搜索简谈
  7. CentOS通过yum安装php7.0
  8. 4. svg学习笔记-文档结构元素和样式的使用
  9. 对如下字符串(234453)[234]{2324}分析它的括号使用是否正确,括号匹配(Java实现)
  10. oracle sql语句实现累加、累减、累乘、累除
  11. 整合mybaties 逆向生成 pojo mapper.xml
  12. fedora如何删除某个包且不删除依赖它的相关包
  13. Python Json模块中dumps、loads、dump、load函数介绍
  14. Javascript、Jquery获取浏览器和屏幕各种高度宽度(单位都为px)
  15. 一行一行读Java源码——LinkedBlockingQueue
  16. JVM调优总结(一):基本概念
  17. Going Home(最小费用最大流)
  18. IE8下window.open 二次无法加载页面
  19. linux 用户和组操作
  20. hibernate实现学生-课程-成绩

热门文章

  1. C++ functional库中的仿函数
  2. pycharm的安装指导教程以及破解
  3. Linux内核--链表结构(二)
  4. C++篇:第四章_函数_知识点大全
  5. 前端性能优化之js,css调用优化
  6. 论文解读(BGRL)《Bootstrapped Representation Learning on Graphs》
  7. React项目中使用wangeditor以及扩展上传附件菜单
  8. 21天学通Python PDF完整版
  9. 忘记VMware vcenter的Administrator@vsphere.local密码
  10. Oracle 数据库表删除重复数据