@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,121 @@
|
|
|
1
|
+
const Imap = require('imap');
|
|
2
|
+
const { simpleParser } = require('mailparser');
|
|
3
|
+
|
|
4
|
+
exports.imapgetrawheaders = async function (options) {
|
|
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_user, '*', 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
|
+
|
|
12
|
+
const mailbox = this.parseOptional(options.mailbox, '*', 'INBOX');
|
|
13
|
+
|
|
14
|
+
console.log(`Connecting to IMAP server... User: ${IMAP_USER}`);
|
|
15
|
+
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const imap = new Imap({
|
|
18
|
+
user: IMAP_USER,
|
|
19
|
+
password: IMAP_PASSWORD,
|
|
20
|
+
host: IMAP_HOST,
|
|
21
|
+
port: IMAP_PORT,
|
|
22
|
+
tls: IMAP_TLS,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
imap.once('error', (err) => {
|
|
26
|
+
console.error(`IMAP Connection Error: ${err.message}`);
|
|
27
|
+
return reject(`IMAP Error: ${err.message}`);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
imap.once('ready', () => {
|
|
31
|
+
console.log('IMAP connection established.');
|
|
32
|
+
|
|
33
|
+
imap.openBox(mailbox, false, (err, box) => {
|
|
34
|
+
if (err) {
|
|
35
|
+
console.error(`Error opening mailbox: ${err.message}`);
|
|
36
|
+
imap.end();
|
|
37
|
+
return reject(`Error opening mailbox: ${err.message}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
console.log(`Mailbox "${mailbox}" opened. Total Messages: ${box.messages.total}`);
|
|
41
|
+
|
|
42
|
+
if (box.messages.total === 0) {
|
|
43
|
+
imap.end();
|
|
44
|
+
console.warn('No messages found.');
|
|
45
|
+
return reject('No messages found.');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
imap.search(['ALL'], (err, results) => {
|
|
49
|
+
if (err || results.length === 0) {
|
|
50
|
+
console.error('No messages available.');
|
|
51
|
+
imap.end();
|
|
52
|
+
return reject('No messages available.');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
console.log(`Found ${results.length} messages. Fetching headers and body...`);
|
|
56
|
+
|
|
57
|
+
const fetch = imap.fetch([results[0]], { bodies: '', struct: true });
|
|
58
|
+
|
|
59
|
+
fetch.on('message', (msg, seqno) => {
|
|
60
|
+
console.log(`Processing message #${seqno}`);
|
|
61
|
+
let headerData = '';
|
|
62
|
+
let bodyData = '';
|
|
63
|
+
let internalDate = '';
|
|
64
|
+
|
|
65
|
+
msg.on('body', (stream, info) => {
|
|
66
|
+
stream.on('data', (chunk) => {
|
|
67
|
+
if (info.which === 'HEADER') {
|
|
68
|
+
headerData += chunk.toString();
|
|
69
|
+
} else {
|
|
70
|
+
bodyData += chunk.toString();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
stream.on('end', async () => {
|
|
75
|
+
try {
|
|
76
|
+
const parsed = await simpleParser(headerData + bodyData);
|
|
77
|
+
console.log(`Parsed Message #${seqno}:`, parsed);
|
|
78
|
+
|
|
79
|
+
resolve({
|
|
80
|
+
id: seqno,
|
|
81
|
+
headers: parsed.headers,
|
|
82
|
+
subject: parsed.subject,
|
|
83
|
+
from: parsed.from?.text,
|
|
84
|
+
to: parsed.to?.text,
|
|
85
|
+
date: parsed.date || internalDate,
|
|
86
|
+
body: parsed.text, // Plain text version of the email
|
|
87
|
+
htmlBody: parsed.html, // HTML version of the email
|
|
88
|
+
});
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error(`Error parsing message: ${error.message}`);
|
|
91
|
+
reject(`Error parsing message: ${error.message}`);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
msg.on('attributes', (attrs) => {
|
|
97
|
+
internalDate = attrs.date?.toUTCString();
|
|
98
|
+
console.log(`Message #${seqno} internal date: ${internalDate}`);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
fetch.once('error', (err) => {
|
|
103
|
+
console.error(`Fetch error: ${err.message}`);
|
|
104
|
+
reject(`Fetch error: ${err.message}`);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
fetch.once('end', () => {
|
|
108
|
+
console.log('Fetching process completed. Closing IMAP connection.');
|
|
109
|
+
imap.end();
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
imap.once('end', () => {
|
|
116
|
+
console.log('IMAP connection closed.');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
imap.connect();
|
|
120
|
+
});
|
|
121
|
+
};
|
|
@@ -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 imapgetrawheaders($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,192 @@
|
|
|
1
|
+
[{
|
|
2
|
+
type: 'imapmailcontent-imapmailcontent',
|
|
3
|
+
module : 'imapmailcontent',
|
|
4
|
+
action : 'imapmailcontent',
|
|
5
|
+
groupTitle : 'Mailer',
|
|
6
|
+
groupIcon : 'fas fa-envelope comp-general',
|
|
7
|
+
title : 'IMAP Get Email Content',
|
|
8
|
+
icon : 'fas fa-solid fa-envelope-open 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: "uid"},
|
|
18
|
+
{type: "object",name: "headers", sub:[
|
|
19
|
+
{type: "object",name: "from", sub: [
|
|
20
|
+
{type: "array",name: "value", sub: [
|
|
21
|
+
{type: "number",name: "address"},
|
|
22
|
+
{type: "number",name: "name"}
|
|
23
|
+
]}
|
|
24
|
+
]},
|
|
25
|
+
|
|
26
|
+
{type: "object",name: "to", sub: [
|
|
27
|
+
{type: "array",name: "value", sub: [
|
|
28
|
+
{type: "number",name: "address"},
|
|
29
|
+
{type: "number",name: "name"}
|
|
30
|
+
]}
|
|
31
|
+
]},
|
|
32
|
+
|
|
33
|
+
{type: "object",name: "cc", sub: [
|
|
34
|
+
{type: "array",name: "value", sub: [
|
|
35
|
+
{type: "number",name: "address"},
|
|
36
|
+
{type: "number",name: "name"}
|
|
37
|
+
]}
|
|
38
|
+
]},
|
|
39
|
+
|
|
40
|
+
{type: "object",name: "bcc", sub: [
|
|
41
|
+
{type: "array",name: "value", sub: [
|
|
42
|
+
{type: "number",name: "address"},
|
|
43
|
+
{type: "number",name: "name"}
|
|
44
|
+
]}
|
|
45
|
+
]},
|
|
46
|
+
{type: "text",name: "subject"},
|
|
47
|
+
{type: "text",name: "date"},
|
|
48
|
+
{type: "text",name: "message-id"},
|
|
49
|
+
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{type: "text",name: "body"},
|
|
53
|
+
{type: "array",name: "attachments" sub: [
|
|
54
|
+
{type: "text",name: "filename"},
|
|
55
|
+
{type: "text",name: "contentType"},
|
|
56
|
+
{type: "text",name: "size"},
|
|
57
|
+
{type: "text",name: "data"}
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
{type: "text",name: "uidvalidity"},
|
|
61
|
+
{type: "text",name: "mailbox"},
|
|
62
|
+
{type: "text",name: "status"}
|
|
63
|
+
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
properties : [
|
|
68
|
+
{
|
|
69
|
+
group: 'IMAP Inputs',
|
|
70
|
+
variables: [
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
{ name: 'actionName',
|
|
74
|
+
optionName: 'name',
|
|
75
|
+
title: 'Name',
|
|
76
|
+
type: 'text',
|
|
77
|
+
required: true,
|
|
78
|
+
baseName: "imap"
|
|
79
|
+
},
|
|
80
|
+
{ name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
|
|
81
|
+
type: 'droplist',
|
|
82
|
+
values: [
|
|
83
|
+
{title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
|
|
84
|
+
{title: 'Enable Manual Overrides', value: 'MANUAL',hide:[],show:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls'] },
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
],
|
|
88
|
+
defaultValue: 'ENV',
|
|
89
|
+
help: 'Choose your TLS settings.',
|
|
90
|
+
initValue: "ENV"
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
{name: 'imap_msg',
|
|
94
|
+
optionName: 'imap_msg',
|
|
95
|
+
title: 'IMAP password',
|
|
96
|
+
type: 'static',
|
|
97
|
+
help: 'IMAP .ENV OVERRIDE SETTINGS'
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
{name: 'imap_host',
|
|
101
|
+
optionName: 'imap_host',
|
|
102
|
+
title: 'IMAP Host',
|
|
103
|
+
type: 'text',
|
|
104
|
+
defaultValue: "", initDisplay: 'none',
|
|
105
|
+
serverDataBindings: true,
|
|
106
|
+
help: 'The IMAP Host Server'
|
|
107
|
+
},
|
|
108
|
+
{name: 'imap_user',
|
|
109
|
+
optionName: 'imap_user',
|
|
110
|
+
title: 'IMAP User',
|
|
111
|
+
type: 'text',
|
|
112
|
+
defaultValue: "", initDisplay: 'none',
|
|
113
|
+
serverDataBindings: true,
|
|
114
|
+
help: 'The IMAP user'
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
{name: 'imap_password',
|
|
118
|
+
optionName: 'imap_password',
|
|
119
|
+
title: 'IMAP password',
|
|
120
|
+
type: 'text',
|
|
121
|
+
defaultValue: "", initDisplay: 'none',
|
|
122
|
+
serverDataBindings: true,
|
|
123
|
+
help: 'The IMAP password'
|
|
124
|
+
},
|
|
125
|
+
{name: 'imap_port',
|
|
126
|
+
optionName: 'imap_port',
|
|
127
|
+
title: 'IMAP Port',
|
|
128
|
+
type: 'text',
|
|
129
|
+
defaultValue: "", initDisplay: 'none',
|
|
130
|
+
serverDataBindings: true,
|
|
131
|
+
help: 'The IMAP port'
|
|
132
|
+
},
|
|
133
|
+
{ name: 'imap_tls', optionName: 'imap_tls', title: 'TLS Settings',
|
|
134
|
+
type: 'droplist',
|
|
135
|
+
values: [
|
|
136
|
+
{title: 'Use ENV if available', value: 'ENV' },
|
|
137
|
+
{title: 'True', value: 'True' },
|
|
138
|
+
{title: 'False', value: 'False' },
|
|
139
|
+
|
|
140
|
+
],
|
|
141
|
+
defaultValue: 'ENV', initDisplay: 'none',
|
|
142
|
+
help: 'Choose your TLS settings.',
|
|
143
|
+
initValue: "ENV"
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
{name: 'imap_msg2',
|
|
147
|
+
optionName: 'imap_msg2',
|
|
148
|
+
title: '',
|
|
149
|
+
type: 'static',
|
|
150
|
+
help: 'API ACTION SETTINGS'
|
|
151
|
+
},
|
|
152
|
+
{ name: 'uid',
|
|
153
|
+
optionName: 'uid',
|
|
154
|
+
title: 'uid',
|
|
155
|
+
type: 'text',
|
|
156
|
+
required: true,
|
|
157
|
+
defaultValue: "0",
|
|
158
|
+
serverDataBindings: true,
|
|
159
|
+
help: 'The uid of the email'
|
|
160
|
+
},
|
|
161
|
+
{ name: 'uidvalidity',
|
|
162
|
+
optionName: 'uidvalidity',
|
|
163
|
+
title: 'uidValidity',
|
|
164
|
+
type: 'text',
|
|
165
|
+
required: true,
|
|
166
|
+
defaultValue: "0",
|
|
167
|
+
serverDataBindings: true,
|
|
168
|
+
help: 'The uidValidity key of the email'
|
|
169
|
+
},
|
|
170
|
+
{ name: 'mailbox',
|
|
171
|
+
optionName: 'mailbox',
|
|
172
|
+
title: 'mailbox',
|
|
173
|
+
type: 'text',
|
|
174
|
+
required: true,
|
|
175
|
+
defaultValue: "INBOX",
|
|
176
|
+
serverDataBindings: true,
|
|
177
|
+
help: 'The mailbox containing the email'
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
{ name: 'output',
|
|
181
|
+
optionName: 'output',
|
|
182
|
+
title: 'Output',
|
|
183
|
+
type: 'boolean',
|
|
184
|
+
defaultValue: false
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
]
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const Imap = require('imap');
|
|
2
|
+
const { simpleParser } = require('mailparser');
|
|
3
|
+
|
|
4
|
+
exports.imapmailcontent = async function (options, name) {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const IMAP_USER = process.env.IMAP_USER;
|
|
7
|
+
const IMAP_PASSWORD = process.env.IMAP_PASSWORD;
|
|
8
|
+
const IMAP_HOST = process.env.IMAP_HOST;
|
|
9
|
+
const IMAP_PORT = process.env.IMAP_PORT;
|
|
10
|
+
|
|
11
|
+
const uid = this.parseRequired(options.uid, '*', "No message UID specified");
|
|
12
|
+
const mailbox = this.parseOptional(options.mailbox, '*', 'INBOX'); // Capture mailbox from options
|
|
13
|
+
const uidvalidity = this.parseRequired(options.uidvalidity, '*', "No message UIDValidity specified");
|
|
14
|
+
|
|
15
|
+
const imapConfig = {
|
|
16
|
+
user: IMAP_USER,
|
|
17
|
+
password: IMAP_PASSWORD,
|
|
18
|
+
host: IMAP_HOST,
|
|
19
|
+
port: IMAP_PORT,
|
|
20
|
+
tls: true
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const imap = new Imap(imapConfig);
|
|
24
|
+
|
|
25
|
+
imap.once('ready', () => {
|
|
26
|
+
imap.openBox(mailbox, false, (err, box) => {
|
|
27
|
+
if (err) {
|
|
28
|
+
imap.end();
|
|
29
|
+
return resolve({
|
|
30
|
+
uid: null,
|
|
31
|
+
headers: {},
|
|
32
|
+
body: '',
|
|
33
|
+
attachments: [],
|
|
34
|
+
uidvalidity: null,
|
|
35
|
+
mailbox: null,
|
|
36
|
+
uidKey: null,
|
|
37
|
+
status: 401
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const fetch = imap.fetch(uid, { bodies: "", struct: true });
|
|
42
|
+
|
|
43
|
+
fetch.on('message', (msg) => {
|
|
44
|
+
let buffer = '';
|
|
45
|
+
let headers = {};
|
|
46
|
+
let messageUID = null; // Capture UID separately
|
|
47
|
+
let uidvalidity = box.uidvalidity; // Capture UIDVALIDITY
|
|
48
|
+
|
|
49
|
+
msg.on('body', (stream) => {
|
|
50
|
+
stream.on('data', (chunk) => buffer += chunk.toString('utf8'));
|
|
51
|
+
stream.on('end', async () => {
|
|
52
|
+
try {
|
|
53
|
+
const parsed = await simpleParser(buffer);
|
|
54
|
+
|
|
55
|
+
headers = {
|
|
56
|
+
from: parsed.headers.get('from'),
|
|
57
|
+
to: parsed.headers.get('to'),
|
|
58
|
+
cc: parsed.headers.get('cc') || '', // Added CC field
|
|
59
|
+
bcc: parsed.headers.get('bcc') || '', // Added BCC field
|
|
60
|
+
subject: parsed.headers.get('subject'),
|
|
61
|
+
date: parsed.headers.get('date'),
|
|
62
|
+
'message-id': parsed.headers.get('message-id')
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
resolve({
|
|
66
|
+
uid: messageUID,
|
|
67
|
+
headers: headers,
|
|
68
|
+
body: parsed.html || parsed.text,
|
|
69
|
+
attachments: parsed.attachments.map(att => ({
|
|
70
|
+
filename: att.filename,
|
|
71
|
+
contentType: att.contentType,
|
|
72
|
+
size: att.size,
|
|
73
|
+
data: att.content.toString('base64')
|
|
74
|
+
})),
|
|
75
|
+
uidvalidity: uidvalidity,
|
|
76
|
+
mailbox: mailbox,
|
|
77
|
+
uidKey: `${uidvalidity}:${messageUID}`,
|
|
78
|
+
status: 200
|
|
79
|
+
});
|
|
80
|
+
} catch (parseError) {
|
|
81
|
+
reject(parseError);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
msg.once('attributes', (attrs) => {
|
|
87
|
+
messageUID = attrs.uid;
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
fetch.once('end', () => {
|
|
92
|
+
imap.end();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
imap.once('error', () => {
|
|
98
|
+
resolve({
|
|
99
|
+
uid: null,
|
|
100
|
+
headers: {},
|
|
101
|
+
body: '',
|
|
102
|
+
attachments: [],
|
|
103
|
+
uidvalidity: null,
|
|
104
|
+
mailbox: null,
|
|
105
|
+
uidKey: null,
|
|
106
|
+
status: 401
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
imap.connect();
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
|
|
@@ -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 imapmailcontent($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,174 @@
|
|
|
1
|
+
[{
|
|
2
|
+
type: 'imapmailheaders-imapmailheaders',
|
|
3
|
+
module : 'imapmailheaders',
|
|
4
|
+
action : 'imapmailheaders',
|
|
5
|
+
groupTitle : 'Mailer',
|
|
6
|
+
groupIcon : 'fas fa-envelope comp-general',
|
|
7
|
+
title : 'IMAP Get Headers',
|
|
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
|
+
[{ name: 'data', type: 'text', sub:[
|
|
18
|
+
{ name: 'id', type: 'number' }
|
|
19
|
+
{ name: 'uid', type: 'number' }
|
|
20
|
+
{
|
|
21
|
+
name: 'headers', type: 'object', sub: [
|
|
22
|
+
{ name: 'from', type: 'array' , sub: [
|
|
23
|
+
{ name: 'address', type: 'text' }]
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
{ name: 'to', type: 'array' , sub: [
|
|
27
|
+
{ name: 'address', type: 'text' }]
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
{ name: 'cc', type: 'array' , sub: [
|
|
31
|
+
{ name: 'address', type: 'text' }]
|
|
32
|
+
},
|
|
33
|
+
{ name: 'bcc', type: 'array' , sub: [
|
|
34
|
+
{ name: 'address', type: 'text' }]
|
|
35
|
+
},
|
|
36
|
+
{ name: 'message-id', type: 'number' } # Array of message-id strings
|
|
37
|
+
{ name: 'messagedate', type: 'text' } # Date/time string
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
{ name: 'flags',type: 'array' sub:[
|
|
41
|
+
{ name: 'flag', type: 'text' }
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
{ name: 'attachmentCount', type: 'number' }
|
|
46
|
+
{ name: 'uidvalidity', type: 'number' }
|
|
47
|
+
{ name: 'mailbox', type: 'text' }
|
|
48
|
+
{ name: 'status', type: 'number' }
|
|
49
|
+
]},
|
|
50
|
+
{ name: 'status', type: 'number' }
|
|
51
|
+
]],
|
|
52
|
+
properties : [
|
|
53
|
+
{
|
|
54
|
+
group: 'IMAP Inputs',
|
|
55
|
+
variables: [
|
|
56
|
+
|
|
57
|
+
{ name: 'actionName',
|
|
58
|
+
optionName: 'name',
|
|
59
|
+
title: 'Name',
|
|
60
|
+
type: 'text',
|
|
61
|
+
required: true,
|
|
62
|
+
baseName: "imap"
|
|
63
|
+
},
|
|
64
|
+
{ name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
|
|
65
|
+
type: 'droplist',
|
|
66
|
+
values: [
|
|
67
|
+
{title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
|
|
68
|
+
{title: 'Enable Manual Overrides', value: 'MANUAL',hide:[],show:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls'] },
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
],
|
|
72
|
+
defaultValue: 'ENV',
|
|
73
|
+
help: 'Choose your TLS settings.',
|
|
74
|
+
initValue: "ENV"
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
{name: 'imap_msg',
|
|
78
|
+
optionName: 'imap_msg',
|
|
79
|
+
title: 'IMAP password',
|
|
80
|
+
type: 'static',
|
|
81
|
+
help: 'IMAP .ENV OVERRIDE SETTINGS'
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
{name: 'imap_host',
|
|
85
|
+
optionName: 'imap_host',
|
|
86
|
+
title: 'IMAP Host',
|
|
87
|
+
type: 'text',
|
|
88
|
+
defaultValue: "", initDisplay: 'none',
|
|
89
|
+
serverDataBindings: true,
|
|
90
|
+
help: 'The IMAP Host Server'
|
|
91
|
+
},
|
|
92
|
+
{name: 'imap_user',
|
|
93
|
+
optionName: 'imap_user',
|
|
94
|
+
title: 'IMAP User',
|
|
95
|
+
type: 'text',
|
|
96
|
+
defaultValue: "", initDisplay: 'none',
|
|
97
|
+
serverDataBindings: true,
|
|
98
|
+
help: 'The IMAP user'
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
{name: 'imap_password',
|
|
102
|
+
optionName: 'imap_password',
|
|
103
|
+
title: 'IMAP password',
|
|
104
|
+
type: 'text',
|
|
105
|
+
defaultValue: "", initDisplay: 'none',
|
|
106
|
+
serverDataBindings: true,
|
|
107
|
+
help: 'The IMAP password'
|
|
108
|
+
},
|
|
109
|
+
{name: 'imap_port',
|
|
110
|
+
optionName: 'imap_port',
|
|
111
|
+
title: 'IMAP Port',
|
|
112
|
+
type: 'text',
|
|
113
|
+
defaultValue: "", initDisplay: 'none',
|
|
114
|
+
serverDataBindings: true,
|
|
115
|
+
help: 'The IMAP port'
|
|
116
|
+
},
|
|
117
|
+
{ name: 'imap_tls', optionName: 'imap_tls', title: 'TLS Settings',
|
|
118
|
+
type: 'droplist',
|
|
119
|
+
values: [
|
|
120
|
+
{title: 'Use ENV if available', value: 'ENV' },
|
|
121
|
+
{title: 'True', value: 'True' },
|
|
122
|
+
{title: 'False', value: 'False' },
|
|
123
|
+
|
|
124
|
+
],
|
|
125
|
+
defaultValue: 'ENV', initDisplay: 'none',
|
|
126
|
+
help: 'Choose your TLS settings.',
|
|
127
|
+
initValue: "ENV"
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
{name: 'imap_msg2',
|
|
131
|
+
optionName: 'imap_msg2',
|
|
132
|
+
title: '',
|
|
133
|
+
type: 'static',
|
|
134
|
+
help: 'API ACTION SETTINGS'
|
|
135
|
+
},
|
|
136
|
+
{ name: 'mailbox',
|
|
137
|
+
optionName: 'mailbox',
|
|
138
|
+
title: 'Mailbox',
|
|
139
|
+
type: 'text',
|
|
140
|
+
required: true,
|
|
141
|
+
defaultValue: "INBOX",
|
|
142
|
+
serverDataBindings: true,
|
|
143
|
+
help: 'The Mailbox to use to collect emails'
|
|
144
|
+
},
|
|
145
|
+
{ name: 'offset',
|
|
146
|
+
optionName: 'offset',
|
|
147
|
+
title: 'offset',
|
|
148
|
+
type: 'text',
|
|
149
|
+
required: true,
|
|
150
|
+
defaultValue: "0",
|
|
151
|
+
serverDataBindings: true,
|
|
152
|
+
help: 'The offset within the emails'
|
|
153
|
+
},
|
|
154
|
+
{ name: 'payload',
|
|
155
|
+
optionName: 'payload',
|
|
156
|
+
title: 'payload',
|
|
157
|
+
type: 'text',
|
|
158
|
+
required: true,
|
|
159
|
+
defaultValue: "25",
|
|
160
|
+
serverDataBindings: true,
|
|
161
|
+
help: 'The number of emails to retrieve'
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
{ name: 'output',
|
|
166
|
+
optionName: 'output',
|
|
167
|
+
title: 'Output',
|
|
168
|
+
type: 'boolean',
|
|
169
|
+
defaultValue: false
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
]}]
|