0.0.12 • Published 6 years ago

emailtools v0.0.12

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

EmailTools

Set of NodeJS functions to make working with emails easier. Please do not expect any sophisticated logic the main goal is to keep it simple and straightforward to use. This module serves as an abstraction layer on top of several great modules for working different email protocols.

EmailTools.SMTP

Provides all the SMTP functions.

Kind: static property of EmailTools

SMTP.connect(options) ⇒ Object

Establish SMTP connection to host

Kind: static method of SMTP
Returns: Object - SMTP connection instance as returned from nodemailer

ParamTypeDescription
optionsObjectConnection options
options.userstringSMTP account user
options.passwordstringSMTP account password
options.hoststringSMTP host server
options.portstringSMTP host server port
options.tlstlsSMTP TLS connection flag

SMTP.test(options) ⇒ Promise

Test SMTP connection

Kind: static method of SMTP
Returns: Promise - Resolved on success and rejected on failure

ParamTypeDescription
optionsObject
options.connectionObjectInput options passed to connect() to establish the connection with host

SMTP.send(options) ⇒ Promise

Send email

Kind: static method of SMTP
Returns: Promise - Resolved on success and rejected on failure

ParamTypeDescription
optionsObject
options.connectionObjectInput options passed to connect() to establish the connection with host
options.templateVarsObjectIf provided the template() function is applied to Subject and HTML
options.dataObjectEmail message definition
options.data.fromstring | ObjectEither string of sender or object having name and address attributes
options.data.tostring | ArrayComma seperated or an Array of recipients
options.data.ccstring | ArrayComma seperated or an Array of recipients
options.data.bccstring | ArrayComma seperated or an Array of recipients
options.data.subjectstringThe subject of the email
options.data.htmlstringActual message send as html (automatically converted and added to a text field)

EmailTools.IMAP

Provides all the IMAP functions.

IMAP connection is established automatically upon every function call. This is as designed since nature of application this module was originally developed wouldn't allow to keep connection alive. This behaviour might be extended in the future to keep connection alive using a flag.

Kind: static property of EmailTools

IMAP.connect(options) ⇒ Imap

Establish IMAP connection to host

Kind: static method of IMAP
Returns: Imap - IMAP connection instance as returned from node-imap

ParamTypeDescription
optionsObjectConnection options
options.userstringIMAP account user
options.passwordstringIMAP account password
options.hoststringIMAP host server
options.portstringIMAP host server port
options.tlstlsIMAP TLS connection flag

IMAP.test(options) ⇒ Promise

Test IMAP connection

Kind: static method of IMAP
Returns: Promise - Resolved on success and rejected on failure

ParamTypeDescription
optionsObject
options.connectionObjectInput options passed to connect() to establish the connection with host

IMAP.getFolders(options) ⇒ Promise

Get whole folder structure for provided IMAP account. Format of the structure is defined by the flags described below - If no flag is set returned format is a string array containing folder identifiers.

Kind: static method of IMAP
Returns: Promise - Resolved with structure defined by the flags above

ParamTypeDescription
optionsObject
options.connectionObjectInput options passed to connect() to establish the connection with host
options.jstreebooleanIf true returned structure is compatible with a jsTree module
options.rawbooleanIf true returned as received from node-imap

IMAP.getFolderInfo(options) ⇒ Promise

Get folder information for provided IMAP account

Kind: static method of IMAP
Returns: Promise - Resolved with the folder IMAP information

ParamTypeDescription
optionsObject
options.connectionObjectInput options passed to connect() to establish the connection with host
options.folderNameObjectName of the folder

IMAP.getLastMessagesHeaders(options) ⇒ Promise

Get headers of latest messages of specified folder for provided account. Number of messages is defined by the length flag.

Seqno is used to sort emails not UID.

Kind: static method of IMAP
Returns: Promise - Resolved with dictionary where Sequence number is used as key and header object as value

ParamTypeDescription
optionsObject
options.connectionObjectInput options passed to connect() to establish the connection with host
options.folderNamestringValid folder name for given IMAP account
options.lengthintNumber of messages returned

IMAP.searchMessageHeaders(options) ⇒ Promise

Search FROM and TO

Kind: static method of IMAP
Returns: Promise - Resolved with dictionary where Sequence number is used as key and header object as value

ParamTypeDescription
optionsObject
options.connectionObjectInput options passed to connect() to establish the connection with host
options.folderNamestringValid folder name for given IMAP account
options.searchstringPhrase to search for

IMAP.readMessage(options) ⇒ Promise

Read and parse message specified by folder name and sequence number.

Kind: static method of IMAP
Returns: Promise - Resolved with MailParser message object

ParamTypeDescription
optionsObject
options.connectionObjectInput options passed to connect() to establish the connection with host
options.folderNamestringValid folder name for given IMAP account
options.messageSeqNointMessage sequence number with the folder

IMAP.readMessages(options) ⇒ Promise

Read and parse messages specified by folder name and sequence number range

Kind: static method of IMAP
Returns: Promise - Resolved with MailParser message object

ParamTypeDescription
optionsObject
options.connectionObjectInput options passed to connect() to establish the connection with host
options.folderNamestringValid folder name for given IMAP account
options.seqNoRangeArray.<int>Sequence number range FROM, TO

IMAP.appendMessage(options) ⇒ Promise

(NOT IMPLEMENTED) Appends message to the given folder of given account

Kind: static method of IMAP

ParamTypeDescription
optionsObject
options.connectionObjectInput options passed to connect() to establish the connection with host
options.folderNamestringValid folder name for the given IMAP account
options.emailObjectEmail object which shall be parsed and appended

EmailTools.template(inputText, vars) ⇒ string

All the text within %?% entries is replaced with a value from matching keys from vars

Kind: static method of EmailTools

ParamTypeDescription
inputTextstringInput text used as a template
varsObjectVariables used to replace template entries
0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago