Отправлять почту через рэйт родной в nodemailer - PullRequest
0 голосов
/ 22 января 2020

Я ищу учебник по отправке почты через почтовый шимпанзе или почтовый узел в реагировать родной. я нашел почтовый узел для реакции. js. так что любой может поделиться кодом для почтовой программы и почтового шимпанзе. так что я могу отправлять почту пользователю, нажав кнопку или после выполнения задачи в моем приложении.

Могу ли я отправлять почту по почте шимпанзе из собственного приложения реагировать

import nodemailer from 'nodemailer';

// async..await is not allowed in global scope, must use a wrapper
async function main() {
  // Generate test SMTP service account from ethereal.email
  // Only needed if you don't have a real mail account for testing
  let testAccount = await nodemailer.createTestAccount();

  // create reusable transporter object using the default SMTP transport
  let transporter = nodemailer.createTransport({
    host: "smtp.ethereal.email",
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
      user: testAccount.user, // generated ethereal user
      pass: testAccount.pass // generated ethereal password
    }
  });

  // send mail with defined transport object
  let info = await transporter.sendMail({
    from: '"Fred Foo ?" <foo@example.com>', // sender address
    to: "bar@example.com, baz@example.com", // list of receivers
    subject: "Hello ✔", // Subject line
    text: "Hello world?", // plain text body
    html: "<b>Hello world?</b>" // html body
  });

  console.log("Message sent: %s", info.messageId);
  // Message sent: <b658f8ca-6296-ccf4-8306-87d57a0b4321@example.com>

  // Preview only available when sending through an Ethereal account
  console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
  // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}

не работает

...