All Projects → a-sk → Node Imapnotify

a-sk / Node Imapnotify

Licence: other
Execute scripts on new messages using IDLE imap command

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Imapnotify

Laravel Imap
Laravel IMAP is an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app.
Stars: ✭ 416 (+994.74%)
Mutual labels:  imap
Deltachat Desktop
Email-based instant messaging for Desktop.
Stars: ✭ 526 (+1284.21%)
Mutual labels:  imap
Docker Mailserver
Production-ready fullstack but simple mail server (SMTP, IMAP, LDAP, Antispam, Antivirus, etc.) running inside a container.
Stars: ✭ 8,115 (+21255.26%)
Mutual labels:  imap
Greenmail
Official master for the Greenmail project
Stars: ✭ 424 (+1015.79%)
Mutual labels:  imap
James Project
Emails at the heart of your business logic!
Stars: ✭ 485 (+1176.32%)
Mutual labels:  imap
Hydroxide
A third-party, open-source ProtonMail CardDAV, IMAP and SMTP bridge
Stars: ✭ 578 (+1421.05%)
Mutual labels:  imap
Mailcow Dockerized
mailcow: dockerized - 🐮 + 🐋 = 💕
Stars: ✭ 4,573 (+11934.21%)
Mutual labels:  imap
Feeds2imap.clj
Pull RSS/Atom feeds to your IMAP folders with Clojure on JVM.
Stars: ✭ 31 (-18.42%)
Mutual labels:  imap
Imap Backup
Backup GMail (or other IMAP) accounts to disk
Stars: ✭ 522 (+1273.68%)
Mutual labels:  imap
Kanmail
📥 An email client that functions like a kanban board.
Stars: ✭ 833 (+2092.11%)
Mutual labels:  imap
Twisted
Event-driven networking engine written in Python.
Stars: ✭ 4,442 (+11589.47%)
Mutual labels:  imap
Neutron
Self-hosted server for the ProtonMail client
Stars: ✭ 452 (+1089.47%)
Mutual labels:  imap
Cypht
Cypht: Lightweight Open Source webmail written in PHP and JavaScript
Stars: ✭ 628 (+1552.63%)
Mutual labels:  imap
Mailkit
A cross-platform .NET library for IMAP, POP3, and SMTP.
Stars: ✭ 4,477 (+11681.58%)
Mutual labels:  imap
Nioimapclient
High performance, async IMAP client implementation
Stars: ✭ 28 (-26.32%)
Mutual labels:  imap
Mail
Library to send e-mails over different transports and protocols (like SMTP and IMAP) using immutable messages and streams. Also includes SMTP server.
Stars: ✭ 399 (+950%)
Mutual labels:  imap
Mail
💌 Mail app for Nextcloud
Stars: ✭ 528 (+1289.47%)
Mutual labels:  imap
Imbox
Python IMAP for Human beings
Stars: ✭ 981 (+2481.58%)
Mutual labels:  imap
How to get emails imap tutorial
How to get emails including there attachments and how to extract various attributes from those emails. See https://youtu.be/zFEEGkvo6O8 for a more detailed information.
Stars: ✭ 30 (-21.05%)
Mutual labels:  imap
Imap
Object-oriented, fully tested PHP IMAP library
Stars: ✭ 678 (+1684.21%)
Mutual labels:  imap

imapnotify

Execute scripts on IMAP mailbox changes (new/deleted/updated messages) using IDLE.

config

{
  "host": "",
  "port": ,
  "tls": true,
  "tlsOptions": { "rejectUnauthorized": false },
  "username": "",
  "password": "",
  "onNotify": "/usr/bin/mbsync test-%s",
  "onNotifyPost": {"mail": "/usr/bin/notmuch new && notify-send 'New mail arrived'"},
  "boxes":
    [
      "box1",
      "box2/box3"
    ]
}
	onNotify:
		[string]: shell command to run on any event
		[object]: shell commands to run on for each type of event
			keys: "mail" for new mail, "update" for existing messages updates, "expunge" for messages deletions
    onNotifyPost:
		[string]: shell command to run after onNotify event
		[object]: shell commands to run after onNotify for each type of event
			keys: "mail" for new mail, "update" for existing messages updates, "expunge" for messages deletions

extra options

    onSIGNAL: a command to run when `SIGNAL` is received.
    onSIGNALpost: a command to run after onSINGAL

Example:

{
  ...
  "onSIGTERM": "/usr/bin/mbsync -a",
  "onSIGTERMpost": "echo 'Bye-Bye'"
  ...
}

config as a node module

Since we load the config file with require(), we can get away with any nodejs module instead of just json. This allows us to be more flexible with the configuration.

In particular, you one can use it to load password from a script rather than having to store it in plain text.

Important: config-module must be requirable (in your $NODE_PATH or given by an absolute path)

Using the latest (>0.12) version of nodejs, one can write myconfig.js as follows. Assuming the script ~/getpass.sh prints out your password. (execSync is a v0.12 feature)

    var child_process = require('child_process');

    function getStdout(cmd) {
        var stdout = child_process.execSync(cmd);
        return stdout.toString().trim();
    }

    exports.host = "<host>"
    exports.port = <port>;
    exports.tls = true;
    exports.tlsOptions = { "rejectUnauthorized": false };
    exports.username = "<user>";
    exports.password = getStdout("~/getpass.sh");
    exports.onNotify = "<sync command>"
    exports.onNotifyPost = "<command>"
    exports.boxes = [ "box1", "box2", "some/other/box" ];

Then you can use

    $ imapnotify -c ~/.config/imap_notify/myconfig.js

Thanks Matthew, for pointing that out!

substitutions

%s in onNotify and onNotifyPost is replaced by the box name.

/ symbol (slash) is replaced by - symbol (minus) so that inbox/junk becomes inbox-junk

example mbsync configuration

IMAPAccount      example
Host             imap.example.com
User             [email protected]
Pass             secret
UseIMAPS         yes

IMAPStore  example-remote
Account    example

MaildirStore  example-local
Path ~/Maildir/mail/example/
Inbox ~/Maildir/mail/example/Inbox
Flatten .


Channel example-inbox
Master :example-remote:INBOX
Slave  :example-local:INBOX

Channel example-github
Master :example-remote:github
Slave  :example-local:github

Channel example-lists-vim-announce
Master :example-remote:lists/vim-announce
Slave  :example-local:lists/vim-announce

install

npm:

npm install -g imapnotify

archlinux aur package:

yaourt -S nodejs-imapnotify

(bonus: systemd.service file)

usage

imapnotify -c /path/to/config
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].