Mail listener library for node.js. Get notification when new email arrived to inbox. Uses IMAP protocol.
Heavily inspired by this gist.
npm install mail-listener
var MailListener = ;var mailListener =username: "imap-username"password: "imap-password"host: "imap-host"port: 993 // imap portsecure: true // use secure connectionmailbox: "INBOX" // mailbox to monitormarkSeen: true // all fetched email willbe marked as seen and not fetched next timefetchUnreadOnStart: true // use it only if you want to get all unread email on lib start. Default is `false`;mailListenerstart;mailListener;mailListener;mailListener;// it's possible to access imap object from node-imap library for performing additional actions. E.x.mailListenerimap
MailListener = require "mail-listener"mailListener =username: "imap-username"password: "imap-password"host: "imap-host"port: 993 # imap portsecure: true # use secure connectionmailbox: "INBOX" # mailbox to monitormarkSeen: true # all fetched email willbe marked as seen and not fetched next timefetchUnreadOnStart: true # use it only if you want to get all unread email on lib start. Default is `false`# start listener. You can stop it calling `stop method`mailListenerstart# subscribe to server connected eventmailListeneron "server:connected"->consolelog "imap connected"# subscribe to error eventsmailListeneron "error"consolelog "error happened"err# mail arrived and was parsed by parsermailListeneron "mail:parsed"# do something with mail object including attachmentsconsolelog "parsed email with attachment"mailattachments## mail processing code goes here## it's possible to access imap object from node-imap library for performing additional actions. E.x.mailListener.imap.move :msguids:mailboxes->
Mail-listener is ready to use in your project. However if you need any feature tell us or fork project and implement it by yourself.
We appreciate feedback!
(The MIT License)
Copyright (c) 2011-2013 CircuitHub., https://circuithub.com/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.