微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在不使用 gmail smtp 的情况下发送电子邮件 nodemailer

如何解决在不使用 gmail smtp 的情况下发送电子邮件 nodemailer

我有一个使用 bell.net 电子邮件地址的企业电子邮件,在他们的网站上,它说使用 smtphm.sympatico.ca 作为 smtp 主机名,以及 port 25 / 587...我有我的nodemailer 代码设置如下:

 app.post('/sendBatchEmail',(req,res) => {
    var emails = [];
    var emailSubject = req.body.emailSubject;
    var emailMessage = req.body.emailMessage;

    //perform db2 send
    var sendEmail = "select * from testemails"
    ibmdb.open(ibmdbconnMaster,function (err,conn) {
      if (err) return console.log(err);
      conn.query(sendEmail,rows) {
        if (err) {
          console.log(err);
        }
        for (var i = 0; i < rows.length; i++) {
          emails.push(rows[i].EMAIL)
        }
       
        //send email
        async function main() {
          
          let transporter = nodemailer.createTransport({
            host: "smtphm.sympatico.ca",port: 25,secure: false,// true for 465,false for other ports
            auth: {
              user: "xxx@bell.net",pass: "xxx",},});
      
          // send mail with defined transport object
          let sendBatch = await transporter.sendMail({
            from: "my1email@bell.net",// sender address
            to: "myemail@gmail.com",bcc: emails,// list of receivers
            subject: emailSubject,// Subject line
            text: emailMessage,// plain text body
          });
          
      
          console.log("Message sent: %s",sendBatch.messageId);
          // Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>
      
          // Preview only available when sending through an Ethereal account
          // console.log("Preview URL: %s",sendBatch.getTestMessageUrl);
          // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
        }
      
        main().catch(console.error);
        res.redirect("/");

        conn.close(function () {
          console.log("closed the function app.get(/sendEmailBatch)");
        });
      });
    });

  })

但是,这不起作用并给我这个错误

    Error: Invalid login: 535 Authentication Failed
    at SMTPConnection._formatError (/Users/ga/Desktop/PSL/mbs/node_modules/nodemailer/lib/smtp-connection/index.js:774:19)
    at SMTPConnection._actionAUTHComplete (/Users/ga/Desktop/PSL/mbs/node_modules/nodemailer/lib/smtp-connection/index.js:1513:34)
    at SMTPConnection.<anonymous> (/Users/ga/Desktop/PSL/mbs/node_modules/nodemailer/lib/smtp-connection/index.js:540:26)
    at SMTPConnection._processResponse (/Users/ga/Desktop/PSL/mmbs/node_modules/nodemailer/lib/smtp-connection/index.js:932:20)
    at SMTPConnection._onData (/Users/ga/Desktop/PSL/mbs/node_modules/nodemailer/lib/smtp-connection/index.js:739:14)
    at TLSSocket.SMTPConnection._onSocketData (/Users/ga/Desktop/PSL/mbs/node_modules/nodemailer/lib/smtp-connection/index.js:189:44)
    at TLSSocket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:223:10) {
  code: 'EAUTH',response: '535 Authentication Failed',responseCode: 535,command: 'AUTH PLAIN'
}

但是当我将其改回 gmail 时有效...有什么想法吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?