format-email-address
v1.1.0
Published
Format an email address before sending email to it. Useful when sending emails with e.g. [Amazon SES](http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html).
Downloads
2,411
Readme
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: '[email protected]' }))
//=> [email protected]
console.log(formatEmailAddress({ name: 'John', address: '[email protected]' }))
//=> John <[email protected]>
console.log(formatEmailAddress({ name: 'John Smith', address: '[email protected]' }))
//=> John Smith <[email protected]>
console.log(formatEmailAddress({ name: 'Jack Sparrow, CPA', address: '[email protected]' }))
//=> "Jack Sparrow, CPA" <[email protected]>
console.log(formatEmailAddress({ name: 'Linus Unnebäck', address: '[email protected]' }))
//=> =?utf-8?Q?Linus_Unneb=C3=A4ck?= <[email protected]>