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

    1、使用nodemailer模块

    var nodemailer = require("nodemailer");

    2、代码如下

    exports.send_email = function(req,res) {
        //发件人信息设置
        var smtpTransport = nodemailer.createTransport("SMTP",{
            host: "smtp.163.com",
            auth: {
                user: "abc@163.com",//账户
                pass: "123456"//密码
            }
        });
    
        //邮件选项设置
        var mailOptions = {
            from: "mrluxh@163.com", // 发件人地址
            to: "123@qq.com,123@139.com", //多个收件人用,分隔
            subject: "Node.js发送邮件测试", // 主题
            html: "<b>我是HTML格式内容</b>" // html body
        }
    
        //发送
        smtpTransport.sendMail(mailOptions, function(error, response){
            if(error){
                console.log(error);
            }else{
                console.log("Message sent: " + response.message);
            }
            smtpTransport.close();
            res.send('ok');
        });
    
    
    
    }
  • 相关阅读:
    20200816
    20200815
    20200813
    20200811
    20200810
    20200806
    20200804
    20200803
    20200802
    20200801
  • 原文地址:https://www.cnblogs.com/luxh/p/3830449.html
Copyright © 2011-2022 走看看