Skip to content

LinusU/format-email-address

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Format Email Address

Format an email address before sending email to it. Useful when sending emails with e.g. Amazon SES.

Will handle Q-encoding for you, so that unicode characters in the name part show up properly.

Installation

npm install --save format-email-address

Usage

const formatEmailAddress = require('format-email-address')

console.log(formatEmailAddress({ name: '', address: 'foo@example.com' }))
//=> foo@example.com

console.log(formatEmailAddress({ name: 'John', address: 'john@example.com' }))
//=> John <john@example.com>

console.log(formatEmailAddress({ name: 'John Smith', address: 'john@example.com' }))
//=> John Smith <john@example.com>

console.log(formatEmailAddress({ name: 'Jack Sparrow, CPA', address: 'jack@example.com' }))
//=> "Jack Sparrow, CPA" <jack@example.com>

console.log(formatEmailAddress({ name: 'Linus Unnebäck', address: 'linus@folkdatorn.se' }))
//=> =?utf-8?Q?Linus_Unneb=C3=A4ck?= <linus@folkdatorn.se>

About

Format an email address before sending email to it

Resources

Stars

Watchers

Forks

Packages

No packages published