Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In nodemailer, How to format text email Body

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.

like image 840
Sawan Kumar Avatar asked Jun 07 '16 10:06

Sawan Kumar


People also ask

How do I send an email template with Nodemailer?

Before we start sending email, the first step is to configure an SMTP transport. A transport is the term Nodemailer uses to describe the method it will use to actually send your email. import nodemailer from 'nodemailer'; const smtp = nodemailer. createTransport({ host: '', port: 587, secure: process.

Can we send HTML with node Mailer module?

NodeMailer is the most famous module used for sending and receiving emails from NodeJS applications. It is a zero dependency module for your NodeJS apps. You can easily send emails as plain text, HTML, or attachments (image, document, etc.).

How do I create a custom domain email in Nodemailer?

You need to configure a transporter with your custom domain info (host, port, user and password) You can find this info in the email configuration of your specific hosting provider. Hi there! I get the message 'email sent' and the function finishes with the status 'ok'.

How do I read email content in node JS?

First, open a connection to the email server using a protocol (SMTP, IMAP, POP) to read email(s) from the email service. The email service can be Gmail, yahoo, outlook. e.t.c. This tutorial uses Imap to read emails and will be using two packages to get the magic started.


1 Answers

You just to add html:

const message = {
  from: "[email protected]",
  to: "[email protected]",
  subject: "Message title",
  text: "Plaintext version of the message",
  html: "<p>HTML version of the message</p>"
};
  • from - The email address of the sender. All email addresses can be plain ‘[email protected]’ or formatted ’“Sender Name” [email protected]‘, see Address object for details.

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

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

  • 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 - The HTML version of the message as an Unicode string, Buffer, Stream or an attachment-like object ({path: ‘http://…‘}).

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

like image 150
corneliouz Bett Avatar answered Oct 19 '22 07:10

corneliouz Bett