@hyperbytes/wappler-imap-manager 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/LICENSE.md +21 -0
- package/README.md +10 -0
- package/package.json +22 -0
- package/server_connect/modules/imapcount.hjson +126 -0
- package/server_connect/modules/imapcount.js +53 -0
- package/server_connect/modules/imapcount.php +17 -0
- package/server_connect/modules/imapcreatefolder.hjson +124 -0
- package/server_connect/modules/imapcreatefolder.js +46 -0
- package/server_connect/modules/imapcreatefolder.php +17 -0
- package/server_connect/modules/imapdelete.hjson +148 -0
- package/server_connect/modules/imapdelete.js +73 -0
- package/server_connect/modules/imapdelete.php +17 -0
- package/server_connect/modules/imapdeletefolder.hjson +125 -0
- package/server_connect/modules/imapdeletefolder.js +65 -0
- package/server_connect/modules/imapdeletefolder.php +17 -0
- package/server_connect/modules/imapdirlist.hjson +122 -0
- package/server_connect/modules/imapdirlist.js +57 -0
- package/server_connect/modules/imapdirlist.php +17 -0
- package/server_connect/modules/imapexpunge.hjson +115 -0
- package/server_connect/modules/imapexpunge.js +63 -0
- package/server_connect/modules/imapexpunge.php +17 -0
- package/server_connect/modules/imapflag.hjson +153 -0
- package/server_connect/modules/imapflag.js +81 -0
- package/server_connect/modules/imapflag.php +17 -0
- package/server_connect/modules/imapgetattachments.hjson +159 -0
- package/server_connect/modules/imapgetattachments.js +94 -0
- package/server_connect/modules/imapgetattachments.php +17 -0
- package/server_connect/modules/imapgetrawheaders.hjson +120 -0
- package/server_connect/modules/imapgetrawheaders.js +121 -0
- package/server_connect/modules/imapgetrawheaders.php +17 -0
- package/server_connect/modules/imapmailcontent.hjson +192 -0
- package/server_connect/modules/imapmailcontent.js +113 -0
- package/server_connect/modules/imapmailcontent.php +17 -0
- package/server_connect/modules/imapmailheaders.hjson +174 -0
- package/server_connect/modules/imapmailheaders.js +184 -0
- package/server_connect/modules/imapmailheaders.php +71 -0
- package/server_connect/modules/imapmovefolder.hjson +158 -0
- package/server_connect/modules/imapmovefolder.js +86 -0
- package/server_connect/modules/imapmovefolder.php +17 -0
- package/server_connect/modules/imapremoveflag.hjson +151 -0
- package/server_connect/modules/imapremoveflag.js +72 -0
- package/server_connect/modules/imapremoveflag.php +17 -0
- package/server_connect/modules/imapsaveasdraft.hjson +202 -0
- package/server_connect/modules/imapsaveasdraft.js +184 -0
- package/server_connect/modules/imapsaveflag.php +17 -0
- package/server_connect/modules/imapsendmail.hjson +190 -0
- package/server_connect/modules/imapsendmail.js +171 -0
- package/server_connect/modules/imapsendmail.php +17 -0
- package/server_connect/modules/imapstore.hjson +160 -0
- package/server_connect/modules/imapstore.js +63 -0
- package/server_connect/modules/imapstore.php +17 -0
- package/server_connect/modules/imapsubscribe.hjson +128 -0
- package/server_connect/modules/imapsubscribe.js +43 -0
- package/server_connect/modules/imapsubscribe.php +17 -0
- package/server_connect/modules/imapsubscribedlist.hjson +122 -0
- package/server_connect/modules/imapsubscribedlist.js +57 -0
- package/server_connect/modules/imapsubscribedlist.php +17 -0
- package/server_connect/modules/imaptrashperms.hjson +115 -0
- package/server_connect/modules/imaptrashperms.js +51 -0
- package/server_connect/modules/imaptrashperms.php +17 -0
- package/server_connect/modules/imapunsubscribedlist.hjson +122 -0
- package/server_connect/modules/imapunsubscribedlist.js +80 -0
- package/server_connect/modules/imapunsubscribedlist.php +17 -0
- package/server_connect/modules/testfile.hjsonx +134 -0
- package/server_connect/modules/testfile.js +28 -0
- package/server_connect/modules/testfile_bug.hjsonx +141 -0
- package/server_connect/modules/testfile_bug.js +8 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
[{
|
|
2
|
+
type: 'imapsubscribedlist-imapsubscribedlist',
|
|
3
|
+
module : 'imapsubscribedlist',
|
|
4
|
+
action : 'imapsubscribedlist',
|
|
5
|
+
groupTitle : 'Mailer',
|
|
6
|
+
groupIcon : 'fas fa-envelope comp-general',
|
|
7
|
+
title : 'IMAP List Subscribed Mailboxes',
|
|
8
|
+
icon : 'fas fa-solid fa-list comp-exec',
|
|
9
|
+
dataPickObject: true,
|
|
10
|
+
usedModules : {
|
|
11
|
+
node: {
|
|
12
|
+
'imap' : '^8.8.19',
|
|
13
|
+
'mailparser' : '^3.7.2'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
dataScheme: [
|
|
17
|
+
{
|
|
18
|
+
type: "array",
|
|
19
|
+
name: "mailboxes",
|
|
20
|
+
sub: [
|
|
21
|
+
{
|
|
22
|
+
type: "text", name: "$value"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
properties : [
|
|
28
|
+
{
|
|
29
|
+
group: 'IMAP Inputs',
|
|
30
|
+
variables: [
|
|
31
|
+
{ name: 'actionName',
|
|
32
|
+
optionName: 'name',
|
|
33
|
+
title: 'Name',
|
|
34
|
+
type: 'text',
|
|
35
|
+
required: true,
|
|
36
|
+
baseName: "imap"
|
|
37
|
+
},
|
|
38
|
+
{ name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
|
|
39
|
+
type: 'droplist',
|
|
40
|
+
values: [
|
|
41
|
+
{title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
|
|
42
|
+
{title: 'Enable Manual Overrides', value: 'MANUAL',hide:[],show:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls'] },
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
],
|
|
46
|
+
defaultValue: 'ENV',
|
|
47
|
+
help: 'Choose your TLS settings.',
|
|
48
|
+
initValue: "ENV"
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
{name: 'imap_msg',
|
|
52
|
+
optionName: 'imap_msg',
|
|
53
|
+
title: 'IMAP password',
|
|
54
|
+
type: 'static',
|
|
55
|
+
help: 'IMAP .ENV OVERRIDE SETTINGS'
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
{name: 'imap_host',
|
|
59
|
+
optionName: 'imap_host',
|
|
60
|
+
title: 'IMAP Host',
|
|
61
|
+
type: 'text',
|
|
62
|
+
defaultValue: "", initDisplay: 'none',
|
|
63
|
+
serverDataBindings: true,
|
|
64
|
+
help: 'The IMAP Host Server'
|
|
65
|
+
},
|
|
66
|
+
{name: 'imap_user',
|
|
67
|
+
optionName: 'imap_user',
|
|
68
|
+
title: 'IMAP User',
|
|
69
|
+
type: 'text',
|
|
70
|
+
defaultValue: "", initDisplay: 'none',
|
|
71
|
+
serverDataBindings: true,
|
|
72
|
+
help: 'The IMAP user'
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
{name: 'imap_password',
|
|
76
|
+
optionName: 'imap_password',
|
|
77
|
+
title: 'IMAP password',
|
|
78
|
+
type: 'text',
|
|
79
|
+
defaultValue: "", initDisplay: 'none',
|
|
80
|
+
serverDataBindings: true,
|
|
81
|
+
help: 'The IMAP password'
|
|
82
|
+
},
|
|
83
|
+
{name: 'imap_port',
|
|
84
|
+
optionName: 'imap_port',
|
|
85
|
+
title: 'IMAP Port',
|
|
86
|
+
type: 'text',
|
|
87
|
+
defaultValue: "", initDisplay: 'none',
|
|
88
|
+
serverDataBindings: true,
|
|
89
|
+
help: 'The IMAP port'
|
|
90
|
+
},
|
|
91
|
+
{ name: 'imap_tls', optionName: 'imap_tls', title: 'TLS Settings',
|
|
92
|
+
type: 'droplist',
|
|
93
|
+
values: [
|
|
94
|
+
{title: 'Use ENV if available', value: 'ENV' },
|
|
95
|
+
{title: 'True', value: 'True' },
|
|
96
|
+
{title: 'False', value: 'False' },
|
|
97
|
+
|
|
98
|
+
],
|
|
99
|
+
defaultValue: 'ENV', initDisplay: 'none',
|
|
100
|
+
help: 'Choose your TLS settings.',
|
|
101
|
+
initValue: "ENV"
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
{name: 'imap_msg2',
|
|
105
|
+
optionName: 'imap_msg2',
|
|
106
|
+
title: '',
|
|
107
|
+
type: 'static',
|
|
108
|
+
help: 'API ACTION SETTINGS'
|
|
109
|
+
},
|
|
110
|
+
{ name: 'output',
|
|
111
|
+
optionName: 'output',
|
|
112
|
+
title: 'Output',
|
|
113
|
+
type: 'boolean',
|
|
114
|
+
defaultValue: false
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
]
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const Imap = require('imap');
|
|
2
|
+
|
|
3
|
+
exports.imapsubscribedlist = async function (options) {
|
|
4
|
+
const IMAP_HOST = this.parseOptional(options.imap_host, '*', process.env.IMAP_HOST);
|
|
5
|
+
const IMAP_PASSWORD = this.parseOptional(options.imap_password, '*', process.env.IMAP_PASSWORD);
|
|
6
|
+
const IMAP_USER = this.parseOptional(options.imap_usesr, '*', process.env.IMAP_USER);
|
|
7
|
+
const IMAP_PORT = this.parseOptional(options.imap_port, '*', process.env.IMAP_PORT);
|
|
8
|
+
const imap_tlsstring = this.parseOptional(options.imap_tls, '*', process.env.IMAP_TLS).toLowerCase();
|
|
9
|
+
const IMAP_TLS = (imap_tlsstring == 'true');
|
|
10
|
+
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
const imap = new Imap({
|
|
13
|
+
user: IMAP_USER,
|
|
14
|
+
password: IMAP_PASSWORD,
|
|
15
|
+
host: IMAP_HOST,
|
|
16
|
+
port: IMAP_PORT,
|
|
17
|
+
tls: IMAP_TLS
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
imap.once('ready', () => {
|
|
21
|
+
imap.getSubscribedBoxes((err, boxes) => {
|
|
22
|
+
if (err) {
|
|
23
|
+
imap.end();
|
|
24
|
+
return reject({ code: 400, error: `Error retrieving mailboxes: ${err.message}` });
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const mailboxList = [];
|
|
28
|
+
|
|
29
|
+
// Function to recursively extract subfolders
|
|
30
|
+
function extractMailboxes(boxes, prefix = '') {
|
|
31
|
+
for (let name in boxes) {
|
|
32
|
+
const fullName = prefix ? `${prefix}/${name}` : name;
|
|
33
|
+
mailboxList.push(fullName);
|
|
34
|
+
if (boxes[name].children) {
|
|
35
|
+
extractMailboxes(boxes[name].children, fullName);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
extractMailboxes(boxes);
|
|
41
|
+
|
|
42
|
+
imap.end();
|
|
43
|
+
resolve({ mailboxes: mailboxList });
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
imap.once('error', (err) => {
|
|
48
|
+
reject({ code: 401, error: `Connection error: ${err.message}` });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
imap.once('end', () => {
|
|
52
|
+
console.log('IMAP connection closed.');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
imap.connect();
|
|
56
|
+
});
|
|
57
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace modules;
|
|
4
|
+
|
|
5
|
+
use \lib\core\Module;
|
|
6
|
+
|
|
7
|
+
class custom extends Module
|
|
8
|
+
{
|
|
9
|
+
public function imapsubscribedlist($options, $name) {
|
|
10
|
+
|
|
11
|
+
$myObj->response = "This function is not yet available in PHP";
|
|
12
|
+
|
|
13
|
+
return json_encode($myObj);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
?>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
[{
|
|
2
|
+
type: 'imaptrashperms-imaptrashperms',
|
|
3
|
+
module : 'imaptrashperms',
|
|
4
|
+
action : 'imaptrashperms',
|
|
5
|
+
groupTitle : 'Mailer',
|
|
6
|
+
groupIcon : 'fas fa-envelope comp-general',
|
|
7
|
+
title : 'IMAP Trash folder permissions',
|
|
8
|
+
icon : 'fas fa-solid fa-check comp-exec',
|
|
9
|
+
dataPickObject: true,
|
|
10
|
+
usedModules : {
|
|
11
|
+
node: {
|
|
12
|
+
'imap' : '^8.8.19',
|
|
13
|
+
'mailparser' : '^3.7.2'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
dataScheme: [
|
|
17
|
+
{ type: "number",name: "count"}
|
|
18
|
+
],
|
|
19
|
+
properties : [
|
|
20
|
+
{
|
|
21
|
+
group: 'IMAP Inputs',
|
|
22
|
+
variables: [
|
|
23
|
+
|
|
24
|
+
{ name: 'actionName',
|
|
25
|
+
optionName: 'name',
|
|
26
|
+
title: 'Name',
|
|
27
|
+
type: 'text',
|
|
28
|
+
required: true,
|
|
29
|
+
baseName: "imap"
|
|
30
|
+
},
|
|
31
|
+
{ name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
|
|
32
|
+
type: 'droplist',
|
|
33
|
+
values: [
|
|
34
|
+
{title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
|
|
35
|
+
{title: 'Enable Manual Overrides', value: 'MANUAL',hide:[],show:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls'] },
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
],
|
|
39
|
+
defaultValue: 'ENV',
|
|
40
|
+
help: 'Choose your TLS settings.',
|
|
41
|
+
initValue: "ENV"
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
{name: 'imap_msg',
|
|
45
|
+
optionName: 'imap_msg',
|
|
46
|
+
title: 'IMAP password',
|
|
47
|
+
type: 'static',
|
|
48
|
+
help: 'IMAP .ENV OVERRIDE SETTINGS'
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
{name: 'imap_host',
|
|
52
|
+
optionName: 'imap_host',
|
|
53
|
+
title: 'IMAP Host',
|
|
54
|
+
type: 'text',
|
|
55
|
+
defaultValue: "", initDisplay: 'none',
|
|
56
|
+
serverDataBindings: true,
|
|
57
|
+
help: 'The IMAP Host Server'
|
|
58
|
+
},
|
|
59
|
+
{name: 'imap_user',
|
|
60
|
+
optionName: 'imap_user',
|
|
61
|
+
title: 'IMAP User',
|
|
62
|
+
type: 'text',
|
|
63
|
+
defaultValue: "", initDisplay: 'none',
|
|
64
|
+
serverDataBindings: true,
|
|
65
|
+
help: 'The IMAP user'
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
{name: 'imap_password',
|
|
69
|
+
optionName: 'imap_password',
|
|
70
|
+
title: 'IMAP password',
|
|
71
|
+
type: 'text',
|
|
72
|
+
defaultValue: "", initDisplay: 'none',
|
|
73
|
+
serverDataBindings: true,
|
|
74
|
+
help: 'The IMAP password'
|
|
75
|
+
},
|
|
76
|
+
{name: 'imap_port',
|
|
77
|
+
optionName: 'imap_port',
|
|
78
|
+
title: 'IMAP Port',
|
|
79
|
+
type: 'text',
|
|
80
|
+
defaultValue: "", initDisplay: 'none',
|
|
81
|
+
serverDataBindings: true,
|
|
82
|
+
help: 'The IMAP port'
|
|
83
|
+
},
|
|
84
|
+
{ name: 'imap_tls', optionName: 'imap_tls', title: 'TLS Settings',
|
|
85
|
+
type: 'droplist',
|
|
86
|
+
values: [
|
|
87
|
+
{title: 'Use ENV if available', value: 'ENV' },
|
|
88
|
+
{title: 'True', value: 'True' },
|
|
89
|
+
{title: 'False', value: 'False' },
|
|
90
|
+
|
|
91
|
+
],
|
|
92
|
+
defaultValue: 'ENV', initDisplay: 'none',
|
|
93
|
+
help: 'Choose your TLS settings.',
|
|
94
|
+
initValue: "ENV"
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
{name: 'imap_msg2',
|
|
98
|
+
optionName: 'imap_msg2',
|
|
99
|
+
title: '',
|
|
100
|
+
type: 'static',
|
|
101
|
+
help: 'API ACTION SETTINGS'
|
|
102
|
+
},
|
|
103
|
+
{ name: 'output',
|
|
104
|
+
optionName: 'output',
|
|
105
|
+
title: 'Output',
|
|
106
|
+
type: 'boolean',
|
|
107
|
+
defaultValue: false
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const Imap = require('imap');
|
|
2
|
+
require('dotenv').config(); // Load environment variables
|
|
3
|
+
|
|
4
|
+
exports.imaptrashperms = async function () {
|
|
5
|
+
const IMAP_HOST = this.parseOptional(options.imap_host, '*', process.env.IMAP_HOST);
|
|
6
|
+
const IMAP_PASSWORD = this.parseOptional(options.imap_password, '*', process.env.IMAP_PASSWORD);
|
|
7
|
+
const IMAP_USER = this.parseOptional(options.imap_usesr, '*', process.env.IMAP_USER);
|
|
8
|
+
const IMAP_PORT = this.parseOptional(options.imap_port, '*', process.env.IMAP_PORT);
|
|
9
|
+
const imap_tlsstring = this.parseOptional(options.imap_tls, '*', process.env.IMAP_TLS).toLowerCase();
|
|
10
|
+
const IMAP_TLS = (imap_tlsstring == 'true');
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
const imap = new Imap({
|
|
13
|
+
user: IMAP_USER,
|
|
14
|
+
password: IMAP_PASSWORD,
|
|
15
|
+
host: IMAP_HOST,
|
|
16
|
+
port: IMAP_PORT,
|
|
17
|
+
tls: IMAP_TLS
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
imap.once('ready', () => {
|
|
21
|
+
const trashFolder = process.env.IMAP_TRASH_NAME || 'Trash'; // Default folder
|
|
22
|
+
|
|
23
|
+
imap.getBoxes((err, boxes) => {
|
|
24
|
+
if (err) return reject({ code: 400, error: err });
|
|
25
|
+
if (!boxes[trashFolder]) return reject({ code: 404, error: 'Trash folder not found' });
|
|
26
|
+
|
|
27
|
+
imap.openBox(trashFolder, true, (err, box) => { // Try opening in read-write mode
|
|
28
|
+
if (err) return reject({ code: 400, error: err });
|
|
29
|
+
|
|
30
|
+
resolve({
|
|
31
|
+
name: trashFolder,
|
|
32
|
+
readOnly: !box.writeable, // Corrected method
|
|
33
|
+
messagesTotal: box.messages.total,
|
|
34
|
+
unseenCount: box.messages.unseen,
|
|
35
|
+
recentCount: box.messages.recent,
|
|
36
|
+
uidValidity: box.uidvalidity,
|
|
37
|
+
uidNext: box.uidnext
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
imap.end();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
imap.once('error', err => reject({ code: 401, error: err }));
|
|
46
|
+
|
|
47
|
+
imap.once('end', () => console.log('IMAP connection closed.'));
|
|
48
|
+
|
|
49
|
+
imap.connect();
|
|
50
|
+
});
|
|
51
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace modules;
|
|
4
|
+
|
|
5
|
+
use \lib\core\Module;
|
|
6
|
+
|
|
7
|
+
class custom extends Module
|
|
8
|
+
{
|
|
9
|
+
public function imaptrashperms($options, $name) {
|
|
10
|
+
|
|
11
|
+
$myObj->response = "This function is not yet available in PHP";
|
|
12
|
+
|
|
13
|
+
return json_encode($myObj);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
?>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
[{
|
|
2
|
+
type: 'imapunsubscribedlist-imapunsubscribedlist',
|
|
3
|
+
module : 'imapunsubscribedlist',
|
|
4
|
+
action : 'imapunsubscribedlist',
|
|
5
|
+
groupTitle : 'Mailer',
|
|
6
|
+
groupIcon : 'fas fa-envelope comp-general',
|
|
7
|
+
title : 'IMAP List UnSubscribed Mailboxes',
|
|
8
|
+
icon : 'fas fa-solid fa-list comp-exec',
|
|
9
|
+
dataPickObject: true,
|
|
10
|
+
usedModules : {
|
|
11
|
+
node: {
|
|
12
|
+
'imap' : '^8.8.19',
|
|
13
|
+
'mailparser' : '^3.7.2'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
dataScheme: [
|
|
17
|
+
{
|
|
18
|
+
type: "array",
|
|
19
|
+
name: "mailboxes",
|
|
20
|
+
sub: [
|
|
21
|
+
{
|
|
22
|
+
type: "text", name: "$value"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
properties : [
|
|
28
|
+
{
|
|
29
|
+
group: 'IMAP Inputs',
|
|
30
|
+
variables: [
|
|
31
|
+
{ name: 'actionName',
|
|
32
|
+
optionName: 'name',
|
|
33
|
+
title: 'Name',
|
|
34
|
+
type: 'text',
|
|
35
|
+
required: true,
|
|
36
|
+
baseName: "imap"
|
|
37
|
+
},
|
|
38
|
+
{ name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
|
|
39
|
+
type: 'droplist',
|
|
40
|
+
values: [
|
|
41
|
+
{title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
|
|
42
|
+
{title: 'Enable Manual Overrides', value: 'MANUAL',hide:[],show:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls'] },
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
],
|
|
46
|
+
defaultValue: 'ENV',
|
|
47
|
+
help: 'Choose your TLS settings.',
|
|
48
|
+
initValue: "ENV"
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
{name: 'imap_msg',
|
|
52
|
+
optionName: 'imap_msg',
|
|
53
|
+
title: 'IMAP password',
|
|
54
|
+
type: 'static',
|
|
55
|
+
help: 'IMAP .ENV OVERRIDE SETTINGS'
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
{name: 'imap_host',
|
|
59
|
+
optionName: 'imap_host',
|
|
60
|
+
title: 'IMAP Host',
|
|
61
|
+
type: 'text',
|
|
62
|
+
defaultValue: "", initDisplay: 'none',
|
|
63
|
+
serverDataBindings: true,
|
|
64
|
+
help: 'The IMAP Host Server'
|
|
65
|
+
},
|
|
66
|
+
{name: 'imap_user',
|
|
67
|
+
optionName: 'imap_user',
|
|
68
|
+
title: 'IMAP User',
|
|
69
|
+
type: 'text',
|
|
70
|
+
defaultValue: "", initDisplay: 'none',
|
|
71
|
+
serverDataBindings: true,
|
|
72
|
+
help: 'The IMAP user'
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
{name: 'imap_password',
|
|
76
|
+
optionName: 'imap_password',
|
|
77
|
+
title: 'IMAP password',
|
|
78
|
+
type: 'text',
|
|
79
|
+
defaultValue: "", initDisplay: 'none',
|
|
80
|
+
serverDataBindings: true,
|
|
81
|
+
help: 'The IMAP password'
|
|
82
|
+
},
|
|
83
|
+
{name: 'imap_port',
|
|
84
|
+
optionName: 'imap_port',
|
|
85
|
+
title: 'IMAP Port',
|
|
86
|
+
type: 'text',
|
|
87
|
+
defaultValue: "", initDisplay: 'none',
|
|
88
|
+
serverDataBindings: true,
|
|
89
|
+
help: 'The IMAP port'
|
|
90
|
+
},
|
|
91
|
+
{ name: 'imap_tls', optionName: 'imap_tls', title: 'TLS Settings',
|
|
92
|
+
type: 'droplist',
|
|
93
|
+
values: [
|
|
94
|
+
{title: 'Use ENV if available', value: 'ENV' },
|
|
95
|
+
{title: 'True', value: 'True' },
|
|
96
|
+
{title: 'False', value: 'False' },
|
|
97
|
+
|
|
98
|
+
],
|
|
99
|
+
defaultValue: 'ENV', initDisplay: 'none',
|
|
100
|
+
help: 'Choose your TLS settings.',
|
|
101
|
+
initValue: "ENV"
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
{name: 'imap_msg2',
|
|
105
|
+
optionName: 'imap_msg2',
|
|
106
|
+
title: '',
|
|
107
|
+
type: 'static',
|
|
108
|
+
help: 'API ACTION SETTINGS'
|
|
109
|
+
},
|
|
110
|
+
{ name: 'output',
|
|
111
|
+
optionName: 'output',
|
|
112
|
+
title: 'Output',
|
|
113
|
+
type: 'boolean',
|
|
114
|
+
defaultValue: false
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
]
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const Imap = require('imap');
|
|
2
|
+
|
|
3
|
+
exports.imapunsubscribedlist = async function (options) {
|
|
4
|
+
const IMAP_HOST = options.imap_host || process.env.IMAP_HOST;
|
|
5
|
+
const IMAP_PASSWORD = options.imap_password || process.env.IMAP_PASSWORD;
|
|
6
|
+
const IMAP_USER = options.imap_user || process.env.IMAP_USER;
|
|
7
|
+
const IMAP_PORT = options.imap_port || process.env.IMAP_PORT;
|
|
8
|
+
const IMAP_TLS = (options.imap_tls || process.env.IMAP_TLS || 'true').toLowerCase() === 'true';
|
|
9
|
+
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
const imap = new Imap({
|
|
12
|
+
user: IMAP_USER,
|
|
13
|
+
password: IMAP_PASSWORD,
|
|
14
|
+
host: IMAP_HOST,
|
|
15
|
+
port: IMAP_PORT,
|
|
16
|
+
tls: IMAP_TLS
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
imap.once('ready', () => {
|
|
20
|
+
let allMailboxes = [];
|
|
21
|
+
let subscribedMailboxes = [];
|
|
22
|
+
|
|
23
|
+
// Fetch all mailboxes
|
|
24
|
+
imap.getBoxes((err, boxes) => {
|
|
25
|
+
if (err) {
|
|
26
|
+
imap.end();
|
|
27
|
+
return reject({ code: 400, error: `Error retrieving all mailboxes: ${err.message}` });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function extractMailboxes(boxes, prefix = '') {
|
|
31
|
+
for (let name in boxes) {
|
|
32
|
+
const fullName = prefix ? `${prefix}/${name}` : name;
|
|
33
|
+
allMailboxes.push(fullName);
|
|
34
|
+
if (boxes[name].children) {
|
|
35
|
+
extractMailboxes(boxes[name].children, fullName);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
extractMailboxes(boxes);
|
|
41
|
+
|
|
42
|
+
// Fetch subscribed mailboxes
|
|
43
|
+
imap.getSubscribedBoxes((err, boxes) => {
|
|
44
|
+
if (err) {
|
|
45
|
+
imap.end();
|
|
46
|
+
return reject({ code: 400, error: `Error retrieving subscribed mailboxes: ${err.message}` });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function extractSubscribedMailboxes(boxes, prefix = '') {
|
|
50
|
+
for (let name in boxes) {
|
|
51
|
+
const fullName = prefix ? `${prefix}/${name}` : name;
|
|
52
|
+
subscribedMailboxes.push(fullName);
|
|
53
|
+
if (boxes[name].children) {
|
|
54
|
+
extractSubscribedMailboxes(boxes[name].children, fullName);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
extractSubscribedMailboxes(boxes);
|
|
60
|
+
|
|
61
|
+
// Filter out subscribed mailboxes
|
|
62
|
+
const nonSubscribedMailboxes = allMailboxes.filter(box => !subscribedMailboxes.includes(box));
|
|
63
|
+
|
|
64
|
+
imap.end();
|
|
65
|
+
resolve({ mailboxes: nonSubscribedMailboxes });
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
imap.once('error', (err) => {
|
|
71
|
+
reject({ code: 401, error: `Connection error: ${err.message}` });
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
imap.once('end', () => {
|
|
75
|
+
console.log('IMAP connection closed.');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
imap.connect();
|
|
79
|
+
});
|
|
80
|
+
};;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace modules;
|
|
4
|
+
|
|
5
|
+
use \lib\core\Module;
|
|
6
|
+
|
|
7
|
+
class custom extends Module
|
|
8
|
+
{
|
|
9
|
+
public function imapunsubscribedlist($options, $name) {
|
|
10
|
+
|
|
11
|
+
$myObj->response = "This function is not yet available in PHP";
|
|
12
|
+
|
|
13
|
+
return json_encode($myObj);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
?>
|