@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,125 @@
|
|
|
1
|
+
[{
|
|
2
|
+
type: 'imapdeletefolder-imapdeletefolder',
|
|
3
|
+
module : 'imapdeletefolder',
|
|
4
|
+
action : 'imapdeletefolder',
|
|
5
|
+
groupTitle : 'Mailer',
|
|
6
|
+
groupIcon : 'fas fa-envelope comp-general',
|
|
7
|
+
title : 'IMAP Delete Folder',
|
|
8
|
+
icon : 'fas fa-solid fa-folder-minus 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: "status"},
|
|
18
|
+
{ type: "text",name: "message"}
|
|
19
|
+
]
|
|
20
|
+
properties : [
|
|
21
|
+
{
|
|
22
|
+
group: 'IMAP Inputs',
|
|
23
|
+
variables: [
|
|
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: 'imapfolder',
|
|
104
|
+
optionName: 'imapfolder',
|
|
105
|
+
title: 'IMAP Folder',
|
|
106
|
+
type: 'text',
|
|
107
|
+
required: true,
|
|
108
|
+
serverDataBindings: true,
|
|
109
|
+
defaultValue: 'INBOX',
|
|
110
|
+
help: 'The folder to delete'
|
|
111
|
+
|
|
112
|
+
},
|
|
113
|
+
{ name: 'output',
|
|
114
|
+
optionName: 'output',
|
|
115
|
+
title: 'Output',
|
|
116
|
+
type: 'boolean',
|
|
117
|
+
defaultValue: false
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const Imap = require('imap');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
exports.imapdeletefolder = async function (options) {
|
|
6
|
+
// Load IMAP credentials from environment variables
|
|
7
|
+
const IMAP_HOST = this.parseOptional(options.imap_host, '*', process.env.IMAP_HOST);
|
|
8
|
+
const IMAP_PASSWORD = this.parseOptional(options.imap_password, '*', process.env.IMAP_PASSWORD);
|
|
9
|
+
const IMAP_USER = this.parseOptional(options.imap_usesr, '*', process.env.IMAP_USER);
|
|
10
|
+
const IMAP_PORT = this.parseOptional(options.imap_port, '*', process.env.IMAP_PORT);
|
|
11
|
+
const imap_tlsstring = this.parseOptional(options.imap_tls, '*', process.env.IMAP_TLS).toLowerCase();
|
|
12
|
+
const IMAP_TLS = (imap_tlsstring == 'true');
|
|
13
|
+
let folder = this.parseRequired(options.imapfolder, '*', 'Folder to delete not specified');
|
|
14
|
+
const separator = process.env.IMAP_SUB_SEPARATOR || '/';
|
|
15
|
+
folder = folder.startsWith("INBOX/") ? folder.substring(6) : folder;
|
|
16
|
+
console.log('folder is: ' + folder)
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const imap = new Imap({
|
|
19
|
+
user: IMAP_USER,
|
|
20
|
+
password: IMAP_PASSWORD,
|
|
21
|
+
host: IMAP_HOST,
|
|
22
|
+
port: IMAP_PORT,
|
|
23
|
+
tls: IMAP_TLS,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
imap.connect();
|
|
27
|
+
|
|
28
|
+
imap.once('ready', () => {
|
|
29
|
+
const folderPath = 'INBOX' + separator + folder;
|
|
30
|
+
imap.delBox(folderPath, (err) => {
|
|
31
|
+
if (err) {
|
|
32
|
+
reject({ status: 400, message: `Error: ${err.message}` });
|
|
33
|
+
} else {
|
|
34
|
+
resolve({ status: 200, message: `Folder "${folderPath}" deleted successfully.` });
|
|
35
|
+
}
|
|
36
|
+
imap.end();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
imap.once('error', (err) => {
|
|
41
|
+
reject({ status: 401, message: `Connection error: ${err.message}` });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
imap.once('end', () => {
|
|
45
|
+
console.log('IMAP connection closed.');
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Example usage:
|
|
51
|
+
(async () => {
|
|
52
|
+
try {
|
|
53
|
+
const createResult = await exports.imapcount({
|
|
54
|
+
imapfolder: folder
|
|
55
|
+
});
|
|
56
|
+
console.log(createResult);
|
|
57
|
+
|
|
58
|
+
const deleteResult = await exports.deleteFolder({
|
|
59
|
+
imapfolder: folder
|
|
60
|
+
});
|
|
61
|
+
console.log(deleteResult);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.error(err);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
@@ -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 imapdeletefolder($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: 'imapdirlist-imapdirlist',
|
|
3
|
+
module : 'imapdirlist',
|
|
4
|
+
action : 'imapdirlist',
|
|
5
|
+
groupTitle : 'Mailer',
|
|
6
|
+
groupIcon : 'fas fa-envelope comp-general',
|
|
7
|
+
title : 'IMAP list 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.imapdirlist = 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.getBoxes((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 imapdirlist($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: 'imapexpunge-imapexpunge',
|
|
3
|
+
module : 'imapexpunge',
|
|
4
|
+
action : 'imapexpunge',
|
|
5
|
+
groupTitle : 'Mailer',
|
|
6
|
+
groupIcon : 'fas fa-envelope comp-general',
|
|
7
|
+
title : 'IMAP Empty Trash',
|
|
8
|
+
icon : 'fas fa-solid fa-eraser comp-exec',
|
|
9
|
+
dataPickObject: true,
|
|
10
|
+
usedModules : {
|
|
11
|
+
node: {
|
|
12
|
+
'imap' : '^8.8.19',
|
|
13
|
+
'mailparser' : '^3.7.2'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
properties : [
|
|
18
|
+
{
|
|
19
|
+
group: 'IMAP Expunge',
|
|
20
|
+
variables: [
|
|
21
|
+
|
|
22
|
+
{ name: 'actionName',
|
|
23
|
+
optionName: 'name',
|
|
24
|
+
title: 'Name',
|
|
25
|
+
type: 'text',
|
|
26
|
+
required: true,
|
|
27
|
+
baseName: "imap"
|
|
28
|
+
},
|
|
29
|
+
{ name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
|
|
30
|
+
type: 'droplist',
|
|
31
|
+
values: [
|
|
32
|
+
{title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
|
|
33
|
+
{title: 'Enable Manual Overrides', value: 'MANUAL',hide:[],show:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls'] },
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
],
|
|
37
|
+
defaultValue: 'ENV',
|
|
38
|
+
help: 'Choose your TLS settings.',
|
|
39
|
+
initValue: "ENV"
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
{name: 'imap_msg',
|
|
43
|
+
optionName: 'imap_msg',
|
|
44
|
+
title: 'IMAP password',
|
|
45
|
+
type: 'static',
|
|
46
|
+
help: 'IMAP .ENV OVERRIDE SETTINGS'
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
{name: 'imap_host',
|
|
50
|
+
optionName: 'imap_host',
|
|
51
|
+
title: 'IMAP Host',
|
|
52
|
+
type: 'text',
|
|
53
|
+
defaultValue: "", initDisplay: 'none',
|
|
54
|
+
serverDataBindings: true,
|
|
55
|
+
help: 'The IMAP Host Server'
|
|
56
|
+
},
|
|
57
|
+
{name: 'imap_user',
|
|
58
|
+
optionName: 'imap_user',
|
|
59
|
+
title: 'IMAP User',
|
|
60
|
+
type: 'text',
|
|
61
|
+
defaultValue: "", initDisplay: 'none',
|
|
62
|
+
serverDataBindings: true,
|
|
63
|
+
help: 'The IMAP user'
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
{name: 'imap_password',
|
|
67
|
+
optionName: 'imap_password',
|
|
68
|
+
title: 'IMAP password',
|
|
69
|
+
type: 'text',
|
|
70
|
+
defaultValue: "", initDisplay: 'none',
|
|
71
|
+
serverDataBindings: true,
|
|
72
|
+
help: 'The IMAP password'
|
|
73
|
+
},
|
|
74
|
+
{name: 'imap_port',
|
|
75
|
+
optionName: 'imap_port',
|
|
76
|
+
title: 'IMAP Port',
|
|
77
|
+
type: 'text',
|
|
78
|
+
defaultValue: "", initDisplay: 'none',
|
|
79
|
+
serverDataBindings: true,
|
|
80
|
+
help: 'The IMAP port'
|
|
81
|
+
},
|
|
82
|
+
{ name: 'imap_tls', optionName: 'imap_tls', title: 'TLS Settings',
|
|
83
|
+
type: 'droplist',
|
|
84
|
+
values: [
|
|
85
|
+
{title: 'Use ENV if available', value: 'ENV' },
|
|
86
|
+
{title: 'True', value: 'True' },
|
|
87
|
+
{title: 'False', value: 'False' },
|
|
88
|
+
|
|
89
|
+
],
|
|
90
|
+
defaultValue: 'ENV', initDisplay: 'none',
|
|
91
|
+
help: 'Choose your TLS settings.',
|
|
92
|
+
initValue: "ENV"
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
{name: 'imap_msg2',
|
|
96
|
+
optionName: 'imap_msg2',
|
|
97
|
+
title: '',
|
|
98
|
+
type: 'static',
|
|
99
|
+
help: 'API ACTION SETTINGS'
|
|
100
|
+
},
|
|
101
|
+
|
|
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,63 @@
|
|
|
1
|
+
const Imap = require('imap');
|
|
2
|
+
|
|
3
|
+
exports.imapexpunge = async function (options, name) {
|
|
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
|
+
function expungeEmail(config) {
|
|
12
|
+
return new Promise((resolve) => {
|
|
13
|
+
const imap = new Imap(config);
|
|
14
|
+
|
|
15
|
+
function openInbox(cb) {
|
|
16
|
+
imap.openBox('INBOX', false, cb);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
imap.once('ready', function () {
|
|
20
|
+
openInbox(function (err) {
|
|
21
|
+
if (err) {
|
|
22
|
+
imap.end();
|
|
23
|
+
return resolve({ mailbox: 'INBOX', status: 401 });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
imap.expunge(function (err) {
|
|
27
|
+
if (err) {
|
|
28
|
+
imap.end();
|
|
29
|
+
return resolve({ mailbox: 'INBOX', status: 401 });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log(`Expunged emails from server.`);
|
|
33
|
+
imap.end();
|
|
34
|
+
resolve({ status: 200 });
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
imap.once('error', function () {
|
|
40
|
+
resolve({ status: 401 });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
imap.once('end', function () {
|
|
44
|
+
console.log('IMAP Connection ended');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
imap.connect();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Config setup
|
|
52
|
+
const config = {
|
|
53
|
+
user: IMAP_USER,
|
|
54
|
+
password: IMAP_PASSWORD,
|
|
55
|
+
host: IMAP_HOST,
|
|
56
|
+
port: IMAP_PORT,
|
|
57
|
+
tls: IMAP_TLS
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return expungeEmail(config);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
|
|
@@ -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 imapexpunge($options, $name) {
|
|
10
|
+
|
|
11
|
+
$myObj->response = "This function is not yet available in PHP";
|
|
12
|
+
|
|
13
|
+
return json_encode($myObj);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
?>
|