从消息中出现错误

From in the message appearing wrong

如何显示发件人的电子邮件?目前,当此人发送电子邮件时,似乎发送电子邮件的人是收到电子邮件的人

let transporter = nodemailer.createTransport({
    service: "gmail",
    host: "smtp.gmail.com",
    auth: {
      user: "***********@gmail.com",
      pass: "********",
    },
  });
  const message = {
    from: `${request.body.name} <${request.body.email}>`,
    to: "**********@gmail.com",
    cc: request.body.email,
    subject: request.body.subject,
    html: `Message`,
  };

您不能在没有访问他的帐户的情况下代表用户发送电子邮件,设置 from 字段不会改变您是发件人的事实。要尝试查看差异,请将电子邮件从您用于 trasporter 的帐户发送到您的另一个帐户。

let transporter = nodemailer.createTransport({
    service: "gmail",
    host: "smtp.gmail.com",
    auth: {
      user: "yourFirstEmail@gmail.com",
      pass: "********",
    },
  });
  const message = {
    from: "yourFirstEmail@gmail.com"`,
    to: "yourSecondEmail@gmail.com",
    cc: request.body.email,
    subject: request.body.subject,
    html: `Message`,
  };

这应该有效。