Skip to content

tinovyatkin/mailbuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mailbuilder

Simplified email message composition library for Node.js

npm codecov node Typed with TypeScript

This is simple library (no dependencies) to generate HTML-only email messages (without attachments) from given parameters. Supports Unicode for names and subject, but encodes only when it's actually required:

const { simpleHtmlEmail } = require('mailbuilder');

const testMsg = {
  from: { name: 'John "Cool" Doe', address: 'john@doe.com' },
  to: [{ name: 'Вася Пупкин', address: 'vasya@pupkin.com' }],
  bcc: [
    { name: 'One Spy', address: 'spy@kremlin.ru' },
    { name: 'Big Eye', address: 'fbi@whitehouse.org' },
  ],
  subject: 'Some 💄 subject',
  html: `This is our <b>html</b> message content
      It's also <i>multiline</i> just in case`,
};
const res = simpleHtmlEmail(testMsg);

/**

res:
From: \\"John \\\\\\"Cool\\\\\\" Doe\\" <john@doe.com>
To: =?utf-8?B?0JLQsNGB0Y8g0J/Rg9C/0LrQuNC9IDx2YXN5YUBwdXBraW4uY29tPg==?=
Content-Type: text/html; charset=utf-8
MIME-Version: 1.0
Bcc: One Spy <spy@kremlin.ru>, Big Eye <fbi@whitehouse.org>
Subject: =?utf-8?B?U29tZSDwn5KEIHN1YmplY3Q=?=

This is our <b>html</b> message content
      It's also <i>multiline</i> just in case"

**/

License

MIT licensed by Konstantin Vyatkin tino@vtkn.io