• 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是个小白,各位谅解!

  • 相关阅读:
    live-server
    vue-插槽
    100%的背影
    Luogu P3243 菜肴制作
    CF512E Fox And Polygon
    BZOJ2523/LOJ2646 聪明的学生
    Luogu P3959 宝藏
    Luogu P2280 激光炸弹
    ACAG 0x02-8 非递归实现组合型枚举
    ACAG 0x02-4 费解的开关
  • 原文地址:https://www.cnblogs.com/Ananiah/p/11899391.html
Copyright © 2020-2023  润新知