【问题标题】:nodemailer sender is emptynodemailer 发件人为空
【发布时间】:2019-06-25 05:20:48
【问题描述】:

我正在尝试将 nodemailer 与不需要任何类型验证的应用程序一起使用。该应用程序所在的服务器已被列入白名单,因此不需要用户名或密码。 我设置我的邮件配置如下:

let mailConfig = {
         pool: true,
        maxConnections: maxConnections,
        maxMessages: maxMessages,
        rateDelta: rateDelta * 1000,
        rateLimit: maxMessages * maxConnections,
        secure: false,
        ignoreTLS: true,
        logger:true,
        host: config.SMTP_Host,
        port: config.SMTP_Port
    };

但是,由于电子邮件的发件人不存在,我不断遇到 550 错误。我发现了另一个 stackoverflow 问题,该问题指出,当您的主机域与用户的域(在这种情况下为未定义的用户)不同的主机域时,发件人会自动设置为该域。这对于为什么我的发件人被设置为空白是有道理的,即使我实际上已经设置了它。

如果用户域不存在,是否有办法阻止 nodemailer 更改发件人以匹配用户域?

还是我完全误解了错误信息?

到目前为止,我已经尝试通过在消息对象中手动设置这些字段,但我不得不承认我不熟悉这种类型的协议。

sender:config.SMTP_Host,
envelope: {
           from: `"Sender Name" <${config.SMTP_Host}>`, // used as MAIL FROM: address for SMTP
           to: `${email}, "${first_name}" <${email}>` // used as RCPT TO: address for SMTP
    }

【问题讨论】:

    标签: javascript node.js nodemailer


    【解决方案1】:

    发件人字段必须包含电子邮件地址而不是主机名。

    如果我们以 gmail 为例,您在 from 字段中输入的内容是

    From: "Sender Name" <smtp.gmail.com>
    

    什么时候应该:

    From: "Sender Name" <sender@gmail.com>
    

    发送服务器正在搜索“smtp.gmail.com”作为电子邮件,但没有找到它,因此您收到一条消息,指出该电子邮件地址不存在。

    【讨论】:

      猜你喜欢
      • 2016-09-24
      • 1970-01-01
      • 1970-01-01
      • 2016-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      相关资源
      最近更新 更多