在 nodemailer 中,如何格式化文本电子邮件正文 [英] In nodemailer, How to format text email Body

查看:69
本文介绍了在 nodemailer 中,如何格式化文本电子邮件正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 nodemailer 中有文本正文.我想格式化电子邮件中的文本.

I have text body in nodemailer. I want to format text in email.

 var mailOptions={
        to      : data.toAddress,
        cc      : data.ccAddress,
        bcc     : data.bccAddress,
        subject : data.subject,
        text    : data.message
    }
    smtpTransport.sendMail(mailOptions, function(error, response){
        if(error){
            callback(null, error);
        }else{
            callback(response);
        }
    });

例如;包括项目符号样式,粗体特定单词.

For eg; inculde bullet style, bold specific word.

但在文档中我没有找到特定部分.

But in documentation I am not finding specific section.

如果有人对此有任何想法,请告诉我.

Kindly let me know if any one has any idea on this.

推荐答案

你只需添加 html:

You just to add html:

const message = {
  from: "sender@server.com",
  to: "receiver@sender.com",
  subject: "Message title",
  text: "Plaintext version of the message",
  html: "<p>HTML version of the message</p>"
};

  • from - 发件人的电子邮件地址.所有电子邮件地址都可以普通的‘sender@server.com’或格式化的‘发件人姓名"sender@server.com‘,详见地址对象.

    • from - The email address of the sender. All email addresses can be plain ‘sender@server.com’ or formatted ’"Sender Name" sender@server.com‘, see Address object for details.

      to - 逗号分隔列表或收件人电子邮件地址数组
      将出现在收件人:字段中.

      to - Comma separated list or an array of recipients email addresses
      that will appear on the To: field.

      bcc - 逗号分隔列表或收件人电子邮件地址数组将出现在密件抄送:字段中.

      bcc - Comma separated list or an array of recipients email addresses that will appear on the Bcc: field.

      subject - 电子邮件的主题.text -
      的纯文本版本消息作为 Unicode 字符串、缓冲区、流或
      类似附件的对象 ({path: ‘/var/data/…’}).

      subject - The subject of the email. text - The plaintext version of
      the message as an Unicode string, Buffer, Stream or an
      attachment-like object ({path: ‘/var/data/…’}).

      html - 作为 Unicode 字符串的消息的 HTML 版本,缓冲区,流或类似附件的对象 ({path: ‘http://...‘}).

      html - The HTML version of the message as an Unicode string, Buffer, Stream or an attachment-like object ({path: ‘http://…‘}).

      attachments - 附件对象数组(请参阅使用附件
      详情).附件也可用于嵌入图像.

      attachments - An array of attachment objects (see Using attachments
      for details). Attachments can be used for embedding images as well.

      这篇关于在 nodemailer 中,如何格式化文本电子邮件正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆