summaryrefslogtreecommitdiff
path: root/app/imap.js
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2021-06-22 00:18:35 +0200
committerDaniel Weipert <code@drogueronin.de>2021-06-22 00:18:35 +0200
commitf6096a18016be63c719d2ce5a27d64363862b0fd (patch)
treefae30d63ff1ad2903236cab86d61cc4978f3dfe9 /app/imap.js
Initial commit
Diffstat (limited to 'app/imap.js')
-rw-r--r--app/imap.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/imap.js b/app/imap.js
new file mode 100644
index 0000000..1ac76a4
--- /dev/null
+++ b/app/imap.js
@@ -0,0 +1,34 @@
+const { ipcMain } = require('electron');
+const { ImapFlow } = require('imapflow');
+
+ipcMain.on('imap:listTree:from', listTreeFrom);
+ipcMain.on('imap:listTree:to', listTreeTo);
+
+async function connect (options) {
+ const client = new ImapFlow({
+ host: options.server,
+ port: options.port,
+ auth: {
+ user: options.username,
+ pass: options.password,
+ },
+ });
+
+ await client.connect();
+
+ return client;
+}
+
+async function listTreeFrom (event, options) {
+ const client = await connect(options);
+
+ event.reply('imap:listTree:from:reply', await client.listTree());
+ await client.logout();
+}
+
+async function listTreeTo (event, options) {
+ const client = await connect(options);
+
+ event.reply('imap:listTree:to:reply', await client.listTree());
+ await client.logout();
+}