npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

emailtools

v0.0.12

Published

Node JS set of tools to ease working with Email protocols

Downloads

4

Readme

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

| Param | Type | Description | | --- | --- | --- | | options | Object | Connection options | | options.user | string | SMTP account user | | options.password | string | SMTP account password | | options.host | string | SMTP host server | | options.port | string | SMTP host server port | | options.tls | tls | SMTP TLS connection flag |

SMTP.test(options) ⇒ Promise

Test SMTP connection

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

| Param | Type | Description | | --- | --- | --- | | options | Object | | | options.connection | Object | Input 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

| Param | Type | Description | | --- | --- | --- | | options | Object | | | options.connection | Object | Input options passed to connect() to establish the connection with host | | options.templateVars | Object | If provided the template() function is applied to Subject and HTML | | options.data | Object | Email message definition | | options.data.from | string | Object | Either string of sender or object having name and address attributes | | options.data.to | string | Array | Comma seperated or an Array of recipients | | options.data.cc | string | Array | Comma seperated or an Array of recipients | | options.data.bcc | string | Array | Comma seperated or an Array of recipients | | options.data.subject | string | The subject of the email | | options.data.html | string | Actual 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

| Param | Type | Description | | --- | --- | --- | | options | Object | Connection options | | options.user | string | IMAP account user | | options.password | string | IMAP account password | | options.host | string | IMAP host server | | options.port | string | IMAP host server port | | options.tls | tls | IMAP TLS connection flag |

IMAP.test(options) ⇒ Promise

Test IMAP connection

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

| Param | Type | Description | | --- | --- | --- | | options | Object | | | options.connection | Object | Input 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

| Param | Type | Description | | --- | --- | --- | | options | Object | | | options.connection | Object | Input options passed to connect() to establish the connection with host | | options.jstree | boolean | If true returned structure is compatible with a jsTree module | | options.raw | boolean | If 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

| Param | Type | Description | | --- | --- | --- | | options | Object | | | options.connection | Object | Input options passed to connect() to establish the connection with host | | options.folderName | Object | Name 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

| Param | Type | Description | | --- | --- | --- | | options | Object | | | options.connection | Object | Input options passed to connect() to establish the connection with host | | options.folderName | string | Valid folder name for given IMAP account | | options.length | int | Number 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

| Param | Type | Description | | --- | --- | --- | | options | Object | | | options.connection | Object | Input options passed to connect() to establish the connection with host | | options.folderName | string | Valid folder name for given IMAP account | | options.search | string | Phrase 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

| Param | Type | Description | | --- | --- | --- | | options | Object | | | options.connection | Object | Input options passed to connect() to establish the connection with host | | options.folderName | string | Valid folder name for given IMAP account | | options.messageSeqNo | int | Message 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

| Param | Type | Description | | --- | --- | --- | | options | Object | | | options.connection | Object | Input options passed to connect() to establish the connection with host | | options.folderName | string | Valid folder name for given IMAP account | | options.seqNoRange | Array.<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

| Param | Type | Description | | --- | --- | --- | | options | Object | | | options.connection | Object | Input options passed to connect() to establish the connection with host | | options.folderName | string | Valid folder name for the given IMAP account | | options.email | Object | Email 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

| Param | Type | Description | | --- | --- | --- | | inputText | string | Input text used as a template | | vars | Object | Variables used to replace template entries |