imap-notify

run a command when email is received
git clone git://jb55.com/imap-notify
Log | Files | Refs | README

commit ff8ca532258d20ee0c3418dccd70c01462dfeaa5
parent c0936c0bb4b7e283bbfeccdbac77f4cb50f71b3b
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 23 Apr 2021 11:37:46 -0700

non-tls option (useful when over wireguard)

Diffstat:
Mindex.js | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/index.js b/index.js @@ -9,6 +9,7 @@ const pass = args[3] || process.env.IMAP_NOTIFY_PASS const cmd = args[4] || process.env.IMAP_NOTIFY_CMD const host = args[5] || process.env.IMAP_NOTIFY_HOST || "imap.gmail.com" const port = args[6] || process.env.IMAP_NOTIFY_PORT || 993 +const use_tls = (args[7] || process.env.IMAP_NOTIFY_TLS || 'yes') === 'yes' const allow = process.env.IMAP_ALLOW_UNAUTHORIZED == null? false : !!process.env.IMAP_ALLOW_UNAUTHORIZED const timeout = process.env.IMAP_IDLE_TIMEOUT || 300000; // 5 mins const verbose = !!process.env.IMAP_VERBOSE; @@ -24,7 +25,9 @@ if (!user || !pass || !cmd) { var ready = false; -const socket = tls.connect({host: host, port: port, rejectUnauthorized: !allow}, () => { +const net = use_tls ? require('tls') : require('net') + +const socket = net.connect({host: host, port: port, rejectUnauthorized: !allow}, () => { function handleNotifications() { socket.on("data", (data) => { var str = data.toString();