zoukankan      html  css  js  c++  java
  • node.js发送邮件

    nodemailer模块的特点:

    • 使用Unicode编码
    • 支持Windows系统,不需要安装依赖
    • 支持纯文本和HTML格式
    • 支持发送附件(包括大型附件)
    • 在HTML中嵌入图片
    • 支持SSL/STARTTLS安全协议
    • 不同的传输方法,可以使用内置也可以使用外部插件的形式
    • 提供自定义插件支持(比如增加DKIM签名,使用markdown代替HTML等等)
    • 支持XOAUTH2登录验证(以及关于更新的令牌反馈)

    安装使用

    npm install nodemailer --save   

    github:https://github.com/nodemailer/nodemailer

    var nodemailer = require('nodemailer');
    var transporter = nodemailer.createTransport({
        //https://github.com/andris9/nodemailer-wellknown#supported-services 支持列表
        service: 'qq',
        port: 465, // SMTP 端口
        secureConnection: true, // 使用 SSL
        auth: {
            user: '768065158@qq.com',
            //这里密码不是qq密码,是你设置的smtp密码
            pass: '*****'
        }
    });
    
    // NB! No need to recreate the transporter object. You can use
    // the same transporter object for all e-mails
    
    // setup e-mail data with unicode symbols
    var mailOptions = {
        from: 'xxx@qq.com', // 发件地址
        to: 'xxx@qq.com', // 收件列表
        subject: 'Hello sir', // 标题
        //text和html两者只支持一种
        text: 'Hello world ?', // 标题
        html: '<b>Hello world ?</b>' // html 内容
    };
    
    // send mail with defined transport object
    transporter.sendMail(mailOptions, function(error, info){
        if(error){
            return console.log(error);
        }
        console.log('Message sent: ' + info.response);
    
    });
  • 相关阅读:
    外部程序启动App
    简单修改文件名python脚本
    监听软键盘的显示
    ActionBar 笔记
    ActionBar 笔记
    Android Lock Pattern 图案解锁
    通过反射实现圆角ImageView
    android 通过命令行启动Apk
    ubuntu svn rabbitvcs 安装
    Android 两个界面间快速切换时,会发现有短暂黑屏
  • 原文地址:https://www.cnblogs.com/cosyer/p/6676650.html
Copyright © 2011-2022 走看看