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: '[email protected]' },
  to: [{ name: 'Вася Пупкин', address: '[email protected]' }],
  bcc: [
    { name: 'One Spy', address: '[email protected]' },
    { name: 'Big Eye', address: '[email protected]' },
  ],
  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\\" <[email protected]>
To: =?utf-8?B?0JLQsNGB0Y8g0J/Rg9C/0LrQuNC9IDx2YXN5YUBwdXBraW4uY29tPg==?=
Content-Type: text/html; charset=utf-8
MIME-Version: 1.0
Bcc: One Spy <[email protected]>, Big Eye <[email protected]>
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 [email protected]