var transporter = nodemailer.createTransport({//v1.0 above do not use 'SMTP' as first param
host: "smtp.xxx.xxx.com",
port: 25,
name:"xx.xx.com",
tls: {
rejectUnauthorized:false,
},
auth: {
user: user,
pass: password
}
}); // setup e-mail data with unicode symbols
var mailOptions = {
date: new Date(),
from: 'noreply@xxx.xxx.com', // sender address
to: 'xxx@xxx.com, xxx@qq.com,', // list of receivers
subject: title, // Subject line
text:content,
html: '<div>'+content.replace(/[\r\n]+/g,'<br />')+'</div>' // html body
}; var msg = yield function(fn){
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
var msg='';
if(error){
msg = 'sendMail fail>>>'+error;
} msg = 'Message sent: ' + (info&&info.response);
transporter.close();
fn(error,msg);
});
}

  KOA 项目内,使用 co 框架扁平化回调函数

文档:

http://nodemailer.com/2-0-0-beta/setup-smtp/

nodemailer 发邮件的更多相关文章

  1. nodeJs的nodemailer发邮件报错hostname/IP doesn't match certificate's altnames怎么解决?

    今天在开发过程中碰到一个问题,即使用node发送邮件时报错hostname/IP doesn't match certificate's altnames,在网上查了解决办法有两个, 加rejectU ...

  2. node.js发邮件

    在node上使用第三方类库(nodemailer)发邮件是一件很esay的事情:) app.js   以QQ邮箱为例 var nodemailer = require('nodemailer'); v ...

  3. # PHP - 使用PHPMailer发邮件

    PHPMailer支持多种邮件发送方式,使用起来非常简单 1.下载PHPMailer https://github.com/PHPMailer/PHPMailer,下载完成加压后, 把下边的两个文件复 ...

  4. Linux发邮件之mail命令

    一.mail命令 1.配置 vim /etc/mail.rc 文件尾增加以下内容 set from=1968089885@qq.com smtp="smtp.qq.com" set ...

  5. 测试MailUtils,作用是发邮件

    package cn.itcast.test; import java.io.IOException; import javax.mail.MessagingException; import jav ...

  6. SQL Server定时自动抓取耗时SQL并归档数据发邮件脚本分享

    SQL Server定时自动抓取耗时SQL并归档数据发邮件脚本分享 第一步建库和建表 USE [master] GO CREATE DATABASE [MonitorElapsedHighSQL] G ...

  7. 学习linux之用mail命令发邮件

    背景 这两天工作比较闲,网上各种冲浪(这个词暴露我的网龄了).看到一位大神的文章更闲 <>.端详一番,原来是用R语言拼接字符串后用shell命令发出去.发现shell命令既然还能直接发邮件 ...

  8. linux mail利用外部邮箱地址发邮件

    mail命令发送邮件需要sendmail或postfix服务 三种常用格式发信 mail -s "标题" xxx@xxx.xxx #第一种方法,你可以把当前shell当成编辑器来用 ...

  9. 打电话,发短信,发邮件,app跳转

    1.打电话 - (IBAction)callPhone1:(id)sender { NSURL *url = [NSURL URLWithString:@"tel://18500441739 ...

随机推荐

  1. The certificate used to sign ***has either expired or has been revoked. An updated certificate is required to sign and install the application

    真机测试的时候弹出这样的提示:The certificate used to sign ***has either expired or has been revoked. An updated ce ...

  2. iOS打包ipa给客户测试流程

    IOS项目开发的过程中经常会用到一个测试的问题,特别是外包的项目,客户拿了那么多钱,看不到产品时时的进度说不过去,而且UI和功能是否和符合用户需求这个很重要,需要客户的认同. 所以就需要时时给开发中的 ...

  3. 《ASP.NET MVC高级编程(4版)》读书笔记(5)表单和HTML辅助方法

    5.1 表单使用 5.1.1 action 和 method 特性 <form action="/Home/Index">     <input name=&qu ...

  4. ubuntu selinux

    apt install selinux-utils apt install policycoreutils https://zhidao.baidu.com/question/917938889387 ...

  5. spring boot使用

    首先spring-boot是个服务框架,更加准确来讲是个微服务框架,实际上来说”微“并不“微”,spring-boot包含很多可嵌入的组件,通过这些组件可以来完成我们的服务, 以往我们使用Spring ...

  6. CPU状态信息us,sy,ni,id,wa,hi,si,st含义

    转自:http://blog.csdn.net/sasoritattoo/article/details/9318893 转自:http://fishermen.iteye.com/blog/1995 ...

  7. 【转载】 wpf无边框的方法以及拖拽的问题

    今天在做wpf程序的时候遇到了一个制作无边框的窗体并且有透明圆角的问题,我把解决的过程写下来,和大家学习 正常窗体必须把WindowStyle="None"这个属性加上去,但是加上 ...

  8. C#通过第三方组件生成二维码(QR Code)和条形码(Bar Code)

    用C#如何生成二维码,我们可以通过现有的第三方dll直接来实现,下面列出几种不同的生成方法: 1):通过QrCodeNet(Gma.QrCodeNet.Encoding.dll)来实现 1.1):首先 ...

  9. 使用 CommandLineApplication 类创建专业的控制台程序

    闲话 在很久很久以前,电脑是命令行/终端/控制台的天下,那屏幕上的光标在行云流水般的键盘敲击下欢快地飞跃着,那一行行的字符输出唰唰唰地滚动着--直到 Windows 95 的出现(那时候我还不知道苹果 ...

  10. RPC框架性能基本比较测试

    RPC框架:gRPC.Thrift.Wildfly.Dubbo 原文链接:http://www.open-open.com/lib/view/open1426302068107.html gRPC是G ...