• nodejs中nodemailer报错: 链接超时 510 connect ETIMEDOUT 127.0.0.1:456(已解决)


    //cmd打印的错误
    Error: connect ETIMEDOUT 127.0.0.1:456 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14) { errno: 'ETIMEDOUT', code: 'ESOCKET', syscall: 'connect', address: '127.0.0.1', port: 456, command: 'CONN' }

    我的代码

    'use strict'
    const nodemailer = require('nodemailer');
    
    //创建邮件发布对象
    let transporter = nodemailer.createTransport({
        host: 'smtp.qq.com',
        port: 456,
        secure: true,
        auth:{
            user:'a_ananiah@foxmail.com',
            pass:'muzshiiihtjfeadi'
        }
    });
    
    function send(maill,code){
        // 邮件信息
        let mailObj = {
            form: '"Fred Foo" <a_ananiah@foxmail.com>',
            to: maill,
            subject: "1902",
            text: `您的验证码是${code},有效期是五分钟!`
        }
        //发送邮件 
        transporter.sendMail(mailObj,(err,data) => {
            console.log(err)
            console.log(data)
        })
    }

    错误原因:变量名大写的原因。变量名称改成小写就OK

    let mailobj = { //此处变量名称改成小写就OK
            form: '"Fred Foo" <a_ananiah@foxmail.com>',
            to: maill,
            subject: "1902",
            text: `您的验证码是${code},有效期是五分钟!`
        }
        //发送邮件 
        transporter.sendMail(mailobj,(err,data) => { //此处变量名称改成小写就OK
            console.log(err)
            console.log(data)
        })

    PS:原谅Ananiah是个小白,各位谅解!

  • 相关阅读:
    最热CPLDFPGA论坛
    DSP Builder开发环境安装
    math.h数学函数库
    (转)Fast Input/Output Registers约束
    用EXCEL去掉最高最低数,网上看到,觉得不错
    GMS6.5.3有0DAY的下载了
    [转]为ArcGIS制作符号
    Total Commander 7.5Beta1的便携版
    关于CAD的一个小发现
    可恶的AP PDF password recovery
  • 原文地址:https://www.cnblogs.com/Ananiah/p/11899391.html
Copyright © 2020-2023  润新知