Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
mail-watcher
Advanced tools
Nodejs library watch inbox email to get notified on new incoming email.
Notify your nodejs scripts of incoming imap mail.
Send mail
event for each new email in IMAP INBOX.
Start listening new mails :
const notifier = require('mail-watcher');
const imap = {
user: "yourimapuser",
password: "yourimappassword",
host: "imap.host.com",
port: 993, // imap port
tls: true,// use secure connection
tlsOptions: { rejectUnauthorized: false }
};
notifier(imap)
.on('mail', mail => console.log(mail))
.start();
Keep it running forever :
const n = notifier(imap);
n.on('end', () => n.start()) // session closed
.on('mail', mail => console.log(mail.from[0].address, mail.subject))
.start();
Note: If using a Gmail account, you will need to do two things:
$ npm install mail-watcher
The constructor function creates a new notifier
. Parameter provide options needed for imap connection.
config
:
host
: imap server hostport
: imap server port numberuser
: imap user namepassword
: imap passwordtls
: need a tle connection to servertlsOptions
: see tls
module optionsmarkSeen
: mark mail as read defaults to truebox
: mail box read from defaults to 'INBOX'search
: search query defaults to ['UNSEEN']connTimeout
: Number of milliseconds to wait for a connection to be established. Default: 10000authTimeout
: Number of milliseconds to wait to be authenticated after a connection has been established. Default: 5000debug
: function - if set, the function will be called with one argument, a string containing some debug info. Default: debug output if enabled.Options from node-imap are also avaliable.
For backward compatibility username
is supported.
custommDbg
: function - if set, the function will be called with args that contain some mail-notifier debug info. Default: debug output if enabled.
example:
const n = notifier(config, (...args) => {
const msg = util.format(...args);
customLogFn(msg);
});
Start listening for incomming emails.
Stop listening and close IMAP connection.
Sent when a connection to the server has been made.
Sent on incoming new unread email. The parsed Mail is given as first parameter to the event listener.
Sent when an error occurs with the IMAP connection. The first parameter is the err
object.
Sent when the IMAP connection is closed. This usually happens after a stop
method call.
This module relies heavily on node-imap. For more advanced usage, please consider using it directly.
Debugging is enabled via the visionmedia/debug module.
To enable debug info add mailnotifier
to the DEBUG env variable :
$>DEBUG=mailnotifier node sample/simple-mail-notifier.js
Or to also have imap module debug info :
$>DEBUG=mailnotifier,imap node sample/simple-mail-notifier.js
FAQs
Nodejs library watch inbox email to get notified on new incoming email.
The npm package mail-watcher receives a total of 3 weekly downloads. As such, mail-watcher popularity was classified as not popular.
We found that mail-watcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.