Skip to content

Format emails according to RFC 5322

Notifications You must be signed in to change notification settings

nxz91/format-email

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Format Email

Format emails according to RFC 5322. Useful for formatting emails before sending them to the Gmail API.

Installation

npm install --save format-email

Usage

const formatEmail = require('format-email')

console.log(formatEmail('[email protected]', '[email protected]', 'Hello, World!', 'This is a small email.'))
// Content-Type: text/plain; charset="us-ascii"
// MIME-Version: 1.0
// Content-Transfer-Encoding: 7bit
// From: [email protected]
// To: [email protected]
// Subject: Hello, World!
//
// This is a small email.

console.log(formatEmail('[email protected]', '[email protected]', 'Hello, Unicode!', 'This is an 📨.'))
// Content-Type: text/plain; charset="utf-8"
// MIME-Version: 1.0
// Content-Transfer-Encoding: base64
// From: [email protected]
// To: [email protected]
// Subject: Hello, Unicode!
//
// VGhpcyBpcyBhbiDwn5OoLg==

API

formatEmail (from: string, to: string, subject: string, body: string): string

Format an email according to RFC 5322. Returns the entire email as a string.

About

Format emails according to RFC 5322

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%