{"id":13682730,"url":"https://github.com/a-sk/node-imapnotify","last_synced_at":"2025-04-30T09:34:04.033Z","repository":{"id":13643264,"uuid":"16336688","full_name":"a-sk/node-imapnotify","owner":"a-sk","description":"Execute scripts on new messages using IDLE imap command","archived":false,"fork":false,"pushed_at":"2022-09-16T18:52:35.000Z","size":18,"stargazers_count":42,"open_issues_count":12,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-02T18:16:33.391Z","etag":null,"topics":["idle","imap","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a-sk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-29T05:56:47.000Z","updated_at":"2024-02-06T12:56:38.000Z","dependencies_parsed_at":"2022-09-15T22:50:14.696Z","dependency_job_id":null,"html_url":"https://github.com/a-sk/node-imapnotify","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-sk%2Fnode-imapnotify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-sk%2Fnode-imapnotify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-sk%2Fnode-imapnotify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-sk%2Fnode-imapnotify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a-sk","download_url":"https://codeload.github.com/a-sk/node-imapnotify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224206200,"owners_count":17273405,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["idle","imap","nodejs"],"created_at":"2024-08-02T13:01:52.038Z","updated_at":"2024-11-12T02:31:38.674Z","avatar_url":"https://github.com/a-sk.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# imapnotify\n\nExecute scripts on IMAP mailbox changes (new/deleted/updated messages) using IDLE.\n\n# config\n\n```javascript\n{\n  \"host\": \"\",\n  \"port\": ,\n  \"tls\": true,\n  \"tlsOptions\": { \"rejectUnauthorized\": false },\n  \"username\": \"\",\n  \"password\": \"\",\n  \"onNotify\": \"/usr/bin/mbsync test-%s\",\n  \"onNotifyPost\": {\"mail\": \"/usr/bin/notmuch new \u0026\u0026 notify-send 'New mail arrived'\"},\n  \"boxes\":\n    [\n      \"box1\",\n      \"box2/box3\"\n    ]\n}\n```\n\n```\n\tonNotify:\n\t\t[string]: shell command to run on any event\n\t\t[object]: shell commands to run on for each type of event\n\t\t\tkeys: \"mail\" for new mail, \"update\" for existing messages updates, \"expunge\" for messages deletions\n    onNotifyPost:\n\t\t[string]: shell command to run after onNotify event\n\t\t[object]: shell commands to run after onNotify for each type of event\n\t\t\tkeys: \"mail\" for new mail, \"update\" for existing messages updates, \"expunge\" for messages deletions\n```\n\n### extra options\n\n```\n    onSIGNAL: a command to run when `SIGNAL` is received.\n    onSIGNALpost: a command to run after onSINGAL\n``` \n\nExample:\n\n```javascript\n{\n  ...\n  \"onSIGTERM\": \"/usr/bin/mbsync -a\",\n  \"onSIGTERMpost\": \"echo 'Bye-Bye'\"\n  ...\n}\n```\n\n# config as a node module\n\nSince we load the config file with require(), we can get away with any nodejs \nmodule instead of just json.\nThis allows us to be more flexible with the configuration.\n\nIn particular, you one can use it to load password from a script rather than\nhaving to store it in plain text.\n\nImportant: config-module must be `requirable` (in your $NODE_PATH or\ngiven by an absolute path)\n\nUsing the latest (\u003e0.12) version of nodejs, one can write myconfig.js as\nfollows.  Assuming the script ~/getpass.sh prints out your password.\n(execSync is a v0.12 feature)\n```javascript\n    var child_process = require('child_process');\n\n    function getStdout(cmd) {\n        var stdout = child_process.execSync(cmd);\n        return stdout.toString().trim();\n    }\n\n    exports.host = \"\u003chost\u003e\"\n    exports.port = \u003cport\u003e;\n    exports.tls = true;\n    exports.tlsOptions = { \"rejectUnauthorized\": false };\n    exports.username = \"\u003cuser\u003e\";\n    exports.password = getStdout(\"~/getpass.sh\");\n    exports.onNotify = \"\u003csync command\u003e\"\n    exports.onNotifyPost = \"\u003ccommand\u003e\"\n    exports.boxes = [ \"box1\", \"box2\", \"some/other/box\" ];\n```\n\nThen you can use\n\n```bash\n    $ imapnotify -c ~/.config/imap_notify/myconfig.js\n```\nThanks Matthew, for pointing that out!\n\n## substitutions\n\n`%s` in `onNotify` and `onNotifyPost` is replaced by the box name.\n\n`/` symbol (slash) is replaced by `-` symbol (minus) so that\n`inbox/junk` becomes `inbox-junk`\n\n\n# example mbsync configuration\n\n```\nIMAPAccount      example\nHost             imap.example.com\nUser             test@example.com\nPass             secret\nUseIMAPS         yes\n\nIMAPStore  example-remote\nAccount    example\n\nMaildirStore  example-local\nPath ~/Maildir/mail/example/\nInbox ~/Maildir/mail/example/Inbox\nFlatten .\n\n\nChannel example-inbox\nMaster :example-remote:INBOX\nSlave  :example-local:INBOX\n\nChannel example-github\nMaster :example-remote:github\nSlave  :example-local:github\n\nChannel example-lists-vim-announce\nMaster :example-remote:lists/vim-announce\nSlave  :example-local:lists/vim-announce\n```\n\n# install\n\nnpm:\n\n```\nnpm install -g imapnotify\n```\n\narchlinux aur package:\n\n```\nyaourt -S nodejs-imapnotify\n```\n(bonus: systemd.service file)\n\n# usage\n\n```\nimapnotify -c /path/to/config\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-sk%2Fnode-imapnotify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa-sk%2Fnode-imapnotify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-sk%2Fnode-imapnotify/lists"}