README
utiljs-emails
JavaScript utility methods for emails
utiljs-emails is part of Util.js.
Classes
- Emails
JavaScript utility methods for emails
- EmailHeaders
Wrapper of email headers that makes header lookup easy.
This class makes it so that the case of header names is not important. For example, Gmail might use "In-Reply-To" whereas iCloud might use "In-reply-to".
Emails
JavaScript utility methods for emails
Kind: global class
Access: public
boolean
emails.isValidEmail(string) ⇒ Returns whether the given string is a valid email.
The regular expression used to validate strings comes from a W3C article.
Kind: instance method of Emails
Returns: boolean
- true if the given string is a valid email or false otherwise
Access: public
Param | Type | Description |
---|---|---|
string | string |
The string to test |
EmailHeaders
emails.wrapHeaders(nameValueArrayOfHeaders) ⇒ Wraps the given nameValueArrayOfHeaders inside an object that makes email-header lookup easy.
When using the returned object, you no longer have to worry about the case (e.g., "In-Reply-To" or "In-reply-to") of email headers.
googleapis's interface to Gmail returns email headers as an array of name-value objects. The following is a sample:
[ { name: 'Delivered-To', value: 'c@creemama.com' }, ... { name: 'Date', value: 'Tue, 10 Jul 2018 10:18:52 -0700' }, ... { name: 'To', value: 'Chris Topher' } ]
Kind: instance method of Emails
Returns: EmailHeaders
- A new EmailHeaders instance
Throws:
TypeError
If nameValueArrayOfHeaders is not an array-like object containing name-value objects
Access: public
Param | Type | Description |
---|---|---|
nameValueArrayOfHeaders | Array |
An array of name-value objects containing email headers |
EmailHeaders
Wrapper of email headers that makes header lookup easy.
This class makes it so that the case of header names is not important. For example, Gmail might use "In-Reply-To" whereas iCloud might use "In-reply-to".
Kind: global class
Access: public
- EmailHeaders
- .deliveredTo() ⇒
undefined
|string
- .date() ⇒
undefined
|string
- .from() ⇒
undefined
|string
- .get(headerName) ⇒
undefined
|string
- .inReplyTo() ⇒
undefined
|string
- .messageId() ⇒
undefined
|string
- .references() ⇒
undefined
|string
- .subject() ⇒
undefined
|string
- .to() ⇒
undefined
|string
- .toString() ⇒
string
- .deliveredTo() ⇒
undefined
| string
emailHeaders.deliveredTo() ⇒ Returns the value of the Delivered-To header
Kind: instance method of EmailHeaders
Returns: undefined
| string
- The value of the Date header as a string or undefined
Access: public
undefined
| string
emailHeaders.date() ⇒ Returns the value of the Date header
Kind: instance method of EmailHeaders
Returns: undefined
| string
- The value of the Date header as a string or undefined
Access: public
undefined
| string
emailHeaders.from() ⇒ Returns the value of the From header
Kind: instance method of EmailHeaders
Returns: undefined
| string
- The value of the From header as a string or undefined
Access: public
undefined
| string
emailHeaders.get(headerName) ⇒ Returns the value of the given headerName
Kind: instance method of EmailHeaders
Returns: undefined
| string
- The value of the given header name as a string or undefined
Throws:
TypeError
If headerName does not have a toLowerCase function
Access: public
Param | Type | Description |
---|---|---|
headerName | string |
The header to look up a value for |
undefined
| string
emailHeaders.inReplyTo() ⇒ Returns the value of the In-Reply-To header
Kind: instance method of EmailHeaders
Returns: undefined
| string
- The value of the In-Reply-To header as a string or undefined
Access: public
undefined
| string
emailHeaders.messageId() ⇒ Returns the value of the Message-Id header
Kind: instance method of EmailHeaders
Returns: undefined
| string
- The value of the Message-Id header as a string or undefined
Access: public
undefined
| string
emailHeaders.references() ⇒ Returns the value of the References header
Kind: instance method of EmailHeaders
Returns: undefined
| string
- The value of the References header as a string or undefined
Access: public
undefined
| string
emailHeaders.subject() ⇒ Returns the value of the Subject header
Kind: instance method of EmailHeaders
Returns: undefined
| string
- The value of the Subject header as a string or undefined
Access: public
undefined
| string
emailHeaders.to() ⇒ Returns the value of the To header
Kind: instance method of EmailHeaders
Returns: undefined
| string
- The value of the To header as a string or undefined
Access: public
string
emailHeaders.toString() ⇒ Returns a string listing the email-header names and values of this object
Kind: instance method of EmailHeaders
Returns: string
- A string representation of this object
Access: public