{"id":16451751,"url":"https://github.com/jcreigno/nodejs-mail-notifier","last_synced_at":"2025-04-04T17:10:59.700Z","repository":{"id":3240824,"uuid":"4277495","full_name":"jcreigno/nodejs-mail-notifier","owner":"jcreigno","description":"nodejs library to listen incoming mail","archived":false,"fork":false,"pushed_at":"2022-08-14T12:48:48.000Z","size":44,"stargazers_count":168,"open_issues_count":19,"forks_count":77,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-12T10:10:03.913Z","etag":null,"topics":["imap","mail","nodejs","notifier"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcreigno.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":"2012-05-09T22:10:56.000Z","updated_at":"2024-09-22T15:57:21.000Z","dependencies_parsed_at":"2022-09-01T13:02:23.747Z","dependency_job_id":null,"html_url":"https://github.com/jcreigno/nodejs-mail-notifier","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcreigno%2Fnodejs-mail-notifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcreigno%2Fnodejs-mail-notifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcreigno%2Fnodejs-mail-notifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcreigno%2Fnodejs-mail-notifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcreigno","download_url":"https://codeload.github.com/jcreigno/nodejs-mail-notifier/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217222,"owners_count":20903009,"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":["imap","mail","nodejs","notifier"],"created_at":"2024-10-11T10:10:15.002Z","updated_at":"2025-04-04T17:10:59.679Z","avatar_url":"https://github.com/jcreigno.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"mail-notifier\n=============\n\n\u003e Notify your nodejs scripts of incoming imap mail.\n\nintroduction\n------------\nSend `mail` event for each new email in IMAP INBOX. \n\nsynopsis\n--------\nStart listening new mails :\n\n```javascript\nconst notifier = require('mail-notifier');\n\nconst imap = {\n  user: \"yourimapuser\",\n  password: \"yourimappassword\",\n  host: \"imap.host.com\",\n  port: 993, // imap port\n  tls: true,// use secure connection\n  tlsOptions: { rejectUnauthorized: false }\n};\n\nnotifier(imap)\n  .on('mail', mail =\u003e console.log(mail))\n  .start();\n```  \n\nKeep it running forever :\n\n```javascript\nconst n = notifier(imap);\nn.on('end', () =\u003e n.start()) // session closed\n  .on('mail', mail =\u003e console.log(mail.from[0].address, mail.subject))\n  .start();\n```\n**Note:** If using a Gmail account, you will need to do two things:\n1. Enable IMAP in your Gmail account settings, which is detailed [here](https://support.google.com/mail/answer/7126229?hl=en).\n2. Authorize \"less secure apps\", which you is laid out in \"Option 2\" [here](https://support.google.com/accounts/answer/6010255?hl=en).\n\ninstallation\n------------\n\n    $ npm install mail-notifier\n\nAPI\n===\n\nnotifier(config, customDbg)\n----------------\nThe constructor function creates a new `notifier`. Parameter provide options needed for imap connection.\n`config` :\n\n* `host` :  imap server host\n* `port` :  imap server port number\n* `user` :  imap user name\n* `password` :  imap password\n* `tls` :  need a tle connection to server\n* `tlsOptions` : see `tls` module options\n* `markSeen`: mark mail as read defaults to true\n* `box` : mail box read from defaults to 'INBOX'\n* `search`: search query defaults to ['UNSEEN']\n* `connTimeout` : Number of milliseconds to wait for a connection to be established. Default: 10000\n* `authTimeout` : Number of milliseconds to wait to be authenticated after a connection has been established. Default: 5000\n* `debug`: *function* - if set, the function will be called with one argument, a string containing some debug info. Default: debug output if [enabled](#debugging).\n\nOptions from [node-imap](https://github.com/mscdex/node-imap#connection-instance-methods) are also avaliable.\n\nFor backward compatibility `username` is supported.\n\n`custommDbg`: *function* - if set, the function will be called with args that contain some mail-notifier debug info. Default: debug output if [enabled](#debugging).\n\nexample:\n```javascript\nconst n = notifier(config, (...args) =\u003e {\n  const msg = util.format(...args);\n  customLogFn(msg);\n});\n```\n\n.start()\n------------------------------------\nStart listening for incomming emails.\n\n.stop()\n------------------------------------\nStop listening and close IMAP connection.\n\nEvents\n======\n\n'connected'\n-----\nSent when a connection to the server has been made.\n\n'mail'\n-----\nSent on incoming new unread email. The parsed Mail is given as first parameter to the event listener.\n\n'error'\n-----\nSent when an error occurs with the IMAP connection. The first parameter is the `err` object.\n\n'end'\n-----\nSent when the IMAP connection is closed. This usually happens after a `stop` method call.\n\nDependencies\n============\n\nThis module relies heavily on [node-imap](https://github.com/mscdex/node-imap). For more advanced usage, please consider\nusing it directly.\n\n\nDebugging\n=========\n\nDebugging is enabled via the [visionmedia/debug](https://github.com/visionmedia/debug) module.\n\nTo enable debug info add `mailnotifier` to the DEBUG env variable :\n\n```sg\n$\u003eDEBUG=mailnotifier node sample/simple-mail-notifier.js\n```\n\nOr to also have imap module debug info :\n\n```sg\n$\u003eDEBUG=mailnotifier,imap node sample/simple-mail-notifier.js\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcreigno%2Fnodejs-mail-notifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcreigno%2Fnodejs-mail-notifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcreigno%2Fnodejs-mail-notifier/lists"}