Nodemailer 不会向 Outlook.office365 帐户发送电子邮件

2024-03-17

我正在尝试从 gmail 帐户发送电子邮件到接收者,即我的大学电子邮件 Outlook.office365 。 它适用于gmail到gmail、gmail到outlook.live、gmail到yahoo

import * as nodemailer from 'nodemailer';

export const send = async (to, from, subject, html) => {
  // let testAccount = await nodemailer.createTestAccount();
  let transporter = nodemailer.createTransport({
    name: 'Example',
    service: 'gmail',
    secure : false,
    port : 587,
    auth: {
      user: process.env.FROM_EMAIL,
      pass: process.env.PASSWORD,
    },
  });
  transporter.verify(function(error, success) {
    if (error) {
      console.log(error);
    } else {
      console.log("Server is ready to take our messages");
    }
  });
  let info = await transporter.sendMail(
    {
      from,
      to  ,
      subject,
      html,
    },
    (err, info) => {
      if (err) {
        console.log(err);
      }

      console.log(info)
    },
  );
  
};


对我来说,这是我意识到的,当发送到 Office365 时,如果 html 没有 html 标签,则不会发送电子邮件。 IE。

这个模板将工作

<html>
 <body>
  Hello and welcome
 </body>
</html>

这个模板不管用:

 <body>
    Hello and welcome
 </body>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Nodemailer 不会向 Outlook.office365 帐户发送电子邮件 的相关文章

随机推荐