Email-Templates/Nodemailer 封不包含模板的电子邮件

Email-Templates/Nodemailer emails not containing template

我正在尝试发送带有 email-templates 的 ejs 模板,但我不太高兴。

邮件发送正常,但不包含任何模板数据。

    const email = new Email ({
        template: 'activateAccount',
        message: {
            from: "noreply@domain.com",
            subject: "Activate your account!",
            to: data.email
        },
        locals: {
            name: data.name,
            url: data.url
        },
        send: true,
        transport: {
            host: "domain.com",
            port: 2525,
            auth: {
                user: "abc",
                pass: "123"
            }
        },
        views: {
            options: {
                extension: 'ejs'
            }
        }
    });

    return await email.send();

有谁知道为什么没有填充模板?

.send 发送电子邮件时使用 locals

const email = new Email({
  message: {
    from: "noreply@domain.com",
    subject: "Activate your account!",
    to: data.email
  },
  send: true,
  transport: {
    host: "domain.com",
    port: 2525,
    auth: {
      user: "abc",
      pass: "123"
    }
  },
  views: {
    options: {
      extension: 'ejs'
    }
  }
});

await email.send({
  template: 'activateAccount',
  locals: {
    name: data.name,
    url: data.url
  }
});

基本上,您可以使用的所有选项都是.send函数本身。