nodemailer-markdown

Markdown content for Nodemailer

MIT 7 个版本
安装
npm install nodemailer-markdown
yarn add nodemailer-markdown
pnpm add nodemailer-markdown
bun add nodemailer-markdown
README

Markdown plugin for Nodemailer

This applies to Nodemailer v1.0+. This plugin adds an option markdown for the Nodemailer e-mail options. This value will be used to populate text and html so you don't have to.

Install

Install from npm

npm install nodemailer-markdown --save

Usage

1. Load the markdown function

var markdown = require('nodemailer-markdown').markdown;

2. Attach it as a 'compile' handler for a nodemailer transport object

nodemailerTransport.use('compile', markdown(options))

Where

  • options - includes options for the marked parser with the following additions:
    • useEmbeddedImages - if true, load or download referenced images and include these as attachments

3. Set a markdown value

Any nodemailer content value can be used: String, Buffer, Stream or an object in the form of {path: filepath/url}

var mailOptions1 = {
    markdown: '# Hello world!\n\nThis is a **markdown** message'
};
var mailOptions2 = {
    markdown: {path: __dirname + '/message.md'}
};

Example

var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport();
transporter.use('compile', markdown());
transporter.sendMail({
    from: '[email protected]',
    to: '[email protected]',
    markdown: '# Hello world!\n\nThis is a **markdown** message'
});

License

MIT

版本列表
1.0.3 2019-04-12
1.0.2 2018-01-05
1.0.1 2016-09-13
1.0.0 2014-08-18
0.1.2 2014-07-10
0.1.1 2014-07-05
0.1.0 2014-07-04