1.1.0 • Published 5 years ago

format-email-address v1.1.0

Weekly downloads
236
License
MIT
Repository
github
Last release
5 years ago

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>
1.1.0

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago