@hyperbytes/wappler-imap-manager 1.0.1 → 1.0.3

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.
Files changed (46) hide show
  1. package/package.json +1 -1
  2. package/server_connect/modules/imapcount.hjson +1 -1
  3. package/server_connect/modules/imapcreatefolder.hjson +1 -1
  4. package/server_connect/modules/imapdelete.hjson +1 -1
  5. package/server_connect/modules/imapdeletefolder.hjson +1 -1
  6. package/server_connect/modules/imapdeletefolder.js +1 -1
  7. package/server_connect/modules/imapdirlist.hjson +1 -1
  8. package/server_connect/modules/imapdirlist.js +1 -0
  9. package/server_connect/modules/imapexpunge.hjson +1 -1
  10. package/server_connect/modules/imapflag.hjson +1 -1
  11. package/server_connect/modules/imapgetattachments.hjson +1 -1
  12. package/server_connect/modules/imapgetrawheaders.hjson +10 -6
  13. package/server_connect/modules/imapgetuidvalidity.hjson +126 -0
  14. package/server_connect/modules/imapgetuidvalidity.js +43 -0
  15. package/server_connect/modules/imapmailcontent.hjson +25 -16
  16. package/server_connect/modules/imapmailheaders.hjson +1 -1
  17. package/server_connect/modules/imapmovefolder.hjson +1 -1
  18. package/server_connect/modules/imapremoveflag.hjson +1 -1
  19. package/server_connect/modules/imapsaveasdraft.hjson +2 -2
  20. package/server_connect/modules/imapsaveasdraft.js +19 -4
  21. package/server_connect/modules/imapsendmail.hjson +1 -1
  22. package/server_connect/modules/imapstore.hjson +1 -1
  23. package/server_connect/modules/imapsubscribe.hjson +1 -1
  24. package/server_connect/modules/imapsubscribedlist.hjson +1 -1
  25. package/server_connect/modules/imaptrashperms.hjson +1 -1
  26. package/server_connect/modules/imapunsubscribedlist.hjson +1 -1
  27. package/server_connect/modules/imapcount.php +0 -17
  28. package/server_connect/modules/imapcreatefolder.php +0 -17
  29. package/server_connect/modules/imapdelete.php +0 -17
  30. package/server_connect/modules/imapdeletefolder.php +0 -17
  31. package/server_connect/modules/imapdirlist.php +0 -17
  32. package/server_connect/modules/imapexpunge.php +0 -17
  33. package/server_connect/modules/imapflag.php +0 -17
  34. package/server_connect/modules/imapgetattachments.php +0 -17
  35. package/server_connect/modules/imapgetrawheaders.php +0 -17
  36. package/server_connect/modules/imapmailcontent.php +0 -17
  37. package/server_connect/modules/imapmailheaders.php +0 -71
  38. package/server_connect/modules/imapmovefolder.php +0 -17
  39. package/server_connect/modules/imapremoveflag.php +0 -17
  40. package/server_connect/modules/imapsaveflag.php +0 -17
  41. package/server_connect/modules/imapsendmail.php +0 -17
  42. package/server_connect/modules/imapstore.php +0 -17
  43. package/server_connect/modules/imapsubscribe.php +0 -17
  44. package/server_connect/modules/imapsubscribedlist.php +0 -17
  45. package/server_connect/modules/imaptrashperms.php +0 -17
  46. package/server_connect/modules/imapunsubscribedlist.php +0 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbytes/wappler-imap-manager",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "IMAP eMail Management for Wappler",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -30,7 +30,7 @@
30
30
  required: true,
31
31
  baseName: "imap"
32
32
  },
33
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
33
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
34
34
  type: 'droplist',
35
35
  values: [
36
36
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -29,7 +29,7 @@
29
29
  required: true,
30
30
  baseName: "imap"
31
31
  },
32
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
32
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
33
33
  type: 'droplist',
34
34
  values: [
35
35
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -33,7 +33,7 @@ groupIcon : 'fas fa-envelope comp-general',
33
33
  required: true,
34
34
  baseName: "imap"
35
35
  },
36
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
36
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
37
37
  type: 'droplist',
38
38
  values: [
39
39
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -28,7 +28,7 @@
28
28
  required: true,
29
29
  baseName: "imap"
30
30
  },
31
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
31
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
32
32
  type: 'droplist',
33
33
  values: [
34
34
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -12,7 +12,7 @@ exports.imapdeletefolder = async function (options) {
12
12
  const IMAP_TLS = (imap_tlsstring == 'true');
13
13
  let folder = this.parseRequired(options.imapfolder, '*', 'Folder to delete not specified');
14
14
  const separator = process.env.IMAP_SUB_SEPARATOR || '/';
15
- folder = folder.startsWith("INBOX/") ? folder.substring(6) : folder;
15
+ folder = folder.startsWith("INBOX" + separator) ? folder.substring(6) : folder;
16
16
  console.log('folder is: ' + folder)
17
17
  return new Promise((resolve, reject) => {
18
18
  const imap = new Imap({
@@ -35,7 +35,7 @@
35
35
  required: true,
36
36
  baseName: "imap"
37
37
  },
38
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
38
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
39
39
  type: 'droplist',
40
40
  values: [
41
41
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -1,5 +1,6 @@
1
1
  const Imap = require('imap');
2
2
 
3
+
3
4
  exports.imapdirlist = async function (options) {
4
5
  const IMAP_HOST = this.parseOptional(options.imap_host, '*', process.env.IMAP_HOST);
5
6
  const IMAP_PASSWORD = this.parseOptional(options.imap_password, '*', process.env.IMAP_PASSWORD);
@@ -26,7 +26,7 @@ groupIcon : 'fas fa-envelope comp-general',
26
26
  required: true,
27
27
  baseName: "imap"
28
28
  },
29
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
29
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
30
30
  type: 'droplist',
31
31
  values: [
32
32
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -31,7 +31,7 @@ groupIcon : 'fas fa-envelope comp-general',
31
31
  required: true,
32
32
  baseName: "imap"
33
33
  },
34
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
34
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
35
35
  type: 'droplist',
36
36
  values: [
37
37
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -36,7 +36,7 @@ groupIcon : 'fas fa-envelope comp-general',
36
36
  required: true,
37
37
  baseName: "imap"
38
38
  },
39
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
39
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
40
40
  type: 'droplist',
41
41
  values: [
42
42
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -27,11 +27,11 @@ groupIcon : 'fas fa-envelope comp-general',
27
27
  required: true,
28
28
  baseName: "imap"
29
29
  },
30
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
30
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
31
31
  type: 'droplist',
32
32
  values: [
33
33
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
34
- {title: 'Enable Manula Overrides', value: 'MANUAL',hide:[],show:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls'] },
34
+ {title: 'Enable Manual Overrides', value: 'MANUAL',hide:[],show:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls'] },
35
35
 
36
36
 
37
37
  ],
@@ -51,7 +51,8 @@ groupIcon : 'fas fa-envelope comp-general',
51
51
  optionName: 'imap_host',
52
52
  title: 'IMAP Host',
53
53
  type: 'text',
54
- defaultValue: "", initDisplay: 'none',
54
+ defaultValue: "",
55
+ initDisplay: 'none',
55
56
  serverDataBindings: true,
56
57
  help: 'The IMAP Host Server'
57
58
  },
@@ -59,7 +60,8 @@ groupIcon : 'fas fa-envelope comp-general',
59
60
  optionName: 'imap_user',
60
61
  title: 'IMAP User',
61
62
  type: 'text',
62
- defaultValue: "", initDisplay: 'none',
63
+ defaultValue: "",
64
+ initDisplay: 'none',
63
65
  serverDataBindings: true,
64
66
  help: 'The IMAP user'
65
67
  },
@@ -68,7 +70,8 @@ groupIcon : 'fas fa-envelope comp-general',
68
70
  optionName: 'imap_password',
69
71
  title: 'IMAP password',
70
72
  type: 'text',
71
- defaultValue: "", initDisplay: 'none',
73
+ defaultValue: "",
74
+ initDisplay: 'none',
72
75
  serverDataBindings: true,
73
76
  help: 'The IMAP password'
74
77
  },
@@ -76,7 +79,8 @@ groupIcon : 'fas fa-envelope comp-general',
76
79
  optionName: 'imap_port',
77
80
  title: 'IMAP Port',
78
81
  type: 'text',
79
- defaultValue: "", initDisplay: 'none',
82
+ defaultValue: "",
83
+ initDisplay: 'none',
80
84
  serverDataBindings: true,
81
85
  help: 'The IMAP port'
82
86
  },
@@ -0,0 +1,126 @@
1
+ [{
2
+ type: 'imapgetuidvalidity-imapgetuidvalidity',
3
+ module : 'imapgetuidvalidity',
4
+ action : 'imapgetuidvalidity',
5
+ groupTitle : 'Mailer',
6
+ groupIcon : 'fas fa-envelope comp-general',
7
+ title : 'IMAP Get mailbox uidValidity',
8
+ icon : 'fas fa-solid fa-hashtag comp-exec',
9
+ dataPickObject: true,
10
+ usedModules : {
11
+ node: {
12
+ 'imap' : '^0.8.19',
13
+ 'mailparser' : '^3.7.2'
14
+ }
15
+ },
16
+ dataScheme: [
17
+ { type:"text", name: 'mailbox' }
18
+ { type: "number",name: "uidvalidity"},
19
+ {type: "number", name: "status"}
20
+ ],
21
+ properties : [
22
+ {
23
+ group: 'IMAP Inputs',
24
+ variables: [
25
+
26
+ { name: 'actionName',
27
+ optionName: 'name',
28
+ title: 'Name',
29
+ type: 'text',
30
+ required: true,
31
+ baseName: "imap"
32
+ },
33
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
34
+ type: 'droplist',
35
+ values: [
36
+ {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
37
+ {title: 'Enable Manual Overrides', value: 'MANUAL',hide:[],show:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls'] },
38
+
39
+
40
+ ],
41
+ defaultValue: 'ENV',
42
+ help: 'Choose your TLS settings.',
43
+ initValue: "ENV"
44
+ },
45
+
46
+ {name: 'imap_msg',
47
+ optionName: 'imap_msg',
48
+ title: 'IMAP password',
49
+ type: 'static',
50
+ help: 'IMAP .ENV OVERRIDE SETTINGS'
51
+ },
52
+
53
+ {name: 'imap_host',
54
+ optionName: 'imap_host',
55
+ title: 'IMAP Host',
56
+ type: 'text',
57
+ defaultValue: "", initDisplay: 'none',
58
+ serverDataBindings: true,
59
+ help: 'The IMAP Host Server'
60
+ },
61
+ {name: 'imap_user',
62
+ optionName: 'imap_user',
63
+ title: 'IMAP User',
64
+ type: 'text',
65
+ defaultValue: "", initDisplay: 'none',
66
+ serverDataBindings: true,
67
+ help: 'The IMAP user'
68
+ },
69
+
70
+ {name: 'imap_password',
71
+ optionName: 'imap_password',
72
+ title: 'IMAP password',
73
+ type: 'text',
74
+ defaultValue: "", initDisplay: 'none',
75
+ serverDataBindings: true,
76
+ help: 'The IMAP password'
77
+ },
78
+ {name: 'imap_port',
79
+ optionName: 'imap_port',
80
+ title: 'IMAP Port',
81
+ type: 'text',
82
+ defaultValue: "", initDisplay: 'none',
83
+ serverDataBindings: true,
84
+ help: 'The IMAP port'
85
+ },
86
+ { name: 'imap_tls', optionName: 'imap_tls', title: 'TLS Settings',
87
+ type: 'droplist',
88
+ values: [
89
+ {title: 'Use ENV if available', value: 'ENV' },
90
+ {title: 'True', value: 'True' },
91
+ {title: 'False', value: 'False' },
92
+
93
+ ],
94
+ defaultValue: 'ENV', initDisplay: 'none',
95
+ help: 'Choose your TLS settings.',
96
+ initValue: "ENV"
97
+ },
98
+
99
+ {name: 'imap_msg2',
100
+ optionName: 'imap_msg2',
101
+ title: '',
102
+ type: 'static',
103
+ help: 'API ACTION SETTINGS'
104
+ },
105
+ { name: 'mailbox',
106
+ optionName: 'mailbox',
107
+ title: 'Mailbox',
108
+ type: 'text',
109
+ required: true,
110
+ defaultValue: "",
111
+ serverDataBindings: true,
112
+ help: 'The Mailbox to get uidValidity'
113
+ },
114
+ { name: 'output',
115
+ optionName: 'output',
116
+ title: 'Output',
117
+ type: 'boolean',
118
+ defaultValue: false
119
+ }
120
+
121
+ ]
122
+ },
123
+
124
+ ]
125
+ }
126
+ ]
@@ -0,0 +1,43 @@
1
+ const Imap = require('imap');
2
+
3
+ exports.imapgetuidvalidity = 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_user, '*', 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
+ const folderName = this.parseRequired(options.mailbox, '*', 'Mailbox not specified');
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.openBox(folderName, false, (err, box) => {
22
+ if (err) {
23
+ imap.end();
24
+ return reject({ mailbox: "", uidvalidity: "", code: 400, error: `Error opening mailbox '${folderName}': ${err.message}` });
25
+ }
26
+
27
+ const uidValidity = box.uidvalidity;
28
+ imap.end();
29
+ resolve({ mailbox: folderName, uidvalidity: uidValidity, status: 200 });
30
+ });
31
+ });
32
+
33
+ imap.once('error', (err) => {
34
+ reject({ mailbox: "", uidvalidity: "", code: 401, error: `Connection error: ${err.message}` });
35
+ });
36
+
37
+ imap.once('end', () => {
38
+ console.log('IMAP connection closed.');
39
+ });
40
+
41
+ imap.connect();
42
+ });
43
+ };
@@ -19,36 +19,45 @@ groupIcon : 'fas fa-envelope comp-general',
19
19
  {type: "object",name: "from", sub: [
20
20
  {type: "array",name: "value", sub: [
21
21
  {type: "number",name: "address"},
22
- {type: "number",name: "name"}
23
- ]}
24
- ]},
25
-
22
+ {type: "number",name: "name"}]},
23
+ {type: "text",name: "html"},
24
+ {type: "text",name: "text"}
25
+ ]
26
+ },
26
27
  {type: "object",name: "to", sub: [
27
28
  {type: "array",name: "value", sub: [
28
29
  {type: "number",name: "address"},
29
- {type: "number",name: "name"}
30
- ]}
31
- ]},
32
-
30
+ {type: "number",name: "name"}]},
31
+ {type: "text",name: "html"},
32
+ {type: "text",name: "text"}
33
+ ]
34
+ },
33
35
  {type: "object",name: "cc", sub: [
34
36
  {type: "array",name: "value", sub: [
35
37
  {type: "number",name: "address"},
36
38
  {type: "number",name: "name"}
37
- ]}
38
- ]},
39
+ ]},
40
+ {type: "text",name: "html"},
41
+ {type: "text",name: "text"}
42
+ ]
43
+ },
39
44
 
40
45
  {type: "object",name: "bcc", sub: [
41
46
  {type: "array",name: "value", sub: [
42
47
  {type: "number",name: "address"},
43
48
  {type: "number",name: "name"}
44
- ]}
45
- ]},
46
- {type: "text",name: "subject"},
47
- {type: "text",name: "date"},
48
- {type: "text",name: "message-id"},
49
+ ]},
50
+ {type: "text",name: "html"},
51
+ {type: "text",name: "text"}
52
+ ]
53
+ }
54
+
49
55
 
50
56
  ]
51
57
  },
58
+ {type: "text",name: "subject"},
59
+ {type: "text",name: "date"},
60
+ {type: "text",name: "message-id"},
52
61
  {type: "text",name: "body"},
53
62
  {type: "array",name: "attachments" sub: [
54
63
  {type: "text",name: "filename"},
@@ -77,7 +86,7 @@ groupIcon : 'fas fa-envelope comp-general',
77
86
  required: true,
78
87
  baseName: "imap"
79
88
  },
80
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
89
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
81
90
  type: 'droplist',
82
91
  values: [
83
92
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -61,7 +61,7 @@ groupIcon : 'fas fa-envelope comp-general',
61
61
  required: true,
62
62
  baseName: "imap"
63
63
  },
64
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
64
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
65
65
  type: 'droplist',
66
66
  values: [
67
67
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -32,7 +32,7 @@ groupIcon : 'fas fa-envelope comp-general',
32
32
  required: true,
33
33
  baseName: "imap"
34
34
  },
35
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
35
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
36
36
  type: 'droplist',
37
37
  values: [
38
38
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -26,7 +26,7 @@ groupIcon : 'fas fa-envelope comp-general',
26
26
  required: true,
27
27
  baseName: "imap"
28
28
  },
29
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
29
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
30
30
  type: 'droplist',
31
31
  values: [
32
32
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -4,7 +4,7 @@
4
4
  action : 'imapsaveasdraft',
5
5
  groupTitle : 'Mailer',
6
6
  groupIcon : 'fas fa-envelope comp-general',
7
- title : 'IMAP Save as Draft (not funtional)',
7
+ title : 'IMAP Save as Draft',
8
8
  icon : 'fas fa-solid fa-pen comp-exec',
9
9
  dataPickObject: true,
10
10
  usedModules : {
@@ -34,7 +34,7 @@ groupIcon : 'fas fa-envelope comp-general',
34
34
  required: true,
35
35
  baseName: "imap"
36
36
  },
37
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
37
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
38
38
  type: 'droplist',
39
39
  values: [
40
40
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -2,7 +2,8 @@ const Imap = require('imap-simple');
2
2
  const nodemailer = require('nodemailer');
3
3
  const mailcomposer = require('mailcomposer');
4
4
  const { simpleParser } = require('mailparser'); // Used for debugging email content
5
-
5
+ const { toSystemPath } = require("../../../lib/core/path");
6
+ const path = require("path");
6
7
  exports.imapsaveasdraft = async function (options) {
7
8
  console.log('Starting IMAP draft save process...');
8
9
 
@@ -39,8 +40,8 @@ exports.imapsaveasdraft = async function (options) {
39
40
  console.log('Subject: ' + subject);
40
41
  const body = this.parseOptional(options.body, "*", ""); // Assuming this is HTML body
41
42
  console.log('Body: ' + body);
42
- const attachments = this.parseOptional(options.attachments, '*', []);
43
- console.log('Attachments: ' + attachments);
43
+ const upload = this.parseOptional(options.attachments, '*', []);
44
+ console.log('Attachments: ' + upload);
44
45
  let folder = this.parseOptional(options.mailbox, '*', 'Drafts'); // Default to 'Drafts'
45
46
  console.log('Folder: ' + folder);
46
47
 
@@ -48,6 +49,20 @@ exports.imapsaveasdraft = async function (options) {
48
49
  const providedUid = this.parseOptional(options.uid, "*", "");
49
50
  console.log('UID: ' + providedUid);
50
51
  console.log(`Attempting to save draft to folder: ${folder}`);
52
+ // Ensure attachments are properly formatted and converted to system paths
53
+ const attachmentList = Array.isArray(upload)
54
+ ? upload.map(file => ({
55
+ ...file, // Keep existing properties
56
+ systemPath: toSystemPath(file.path) // Convert relative path to system path
57
+ }))
58
+ : [];
59
+
60
+
61
+ // Prepare attachments for Nodemailer
62
+ const formattedAttachments = attachmentList.map(file => ({
63
+ filename: path.basename(file.systemPath),
64
+ path: file.systemPath // Use transformed system path
65
+ }));
51
66
 
52
67
  const imapConfig = {
53
68
  imap: {
@@ -72,7 +87,7 @@ exports.imapsaveasdraft = async function (options) {
72
87
  bcc: bcc,
73
88
  subject: subject,
74
89
  html: body, // Use 'text' if it's plain text
75
- attachments: attachments
90
+ attachments: formattedAttachments
76
91
  };
77
92
 
78
93
  const mail = mailcomposer(mailOptions);
@@ -30,7 +30,7 @@
30
30
  required: true,
31
31
  baseName: "imap"
32
32
  },
33
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
33
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
34
34
  type: 'droplist',
35
35
  values: [
36
36
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -26,7 +26,7 @@ groupIcon : 'fas fa-envelope comp-general',
26
26
  required: true,
27
27
  baseName: "imap"
28
28
  },
29
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
29
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
30
30
  type: 'droplist',
31
31
  values: [
32
32
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -30,7 +30,7 @@ groupIcon : 'fas fa-envelope comp-general',
30
30
  required: true,
31
31
  baseName: "imap"
32
32
  },
33
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
33
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
34
34
  type: 'droplist',
35
35
  values: [
36
36
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -35,7 +35,7 @@
35
35
  required: true,
36
36
  baseName: "imap"
37
37
  },
38
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
38
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
39
39
  type: 'droplist',
40
40
  values: [
41
41
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -28,7 +28,7 @@
28
28
  required: true,
29
29
  baseName: "imap"
30
30
  },
31
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
31
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
32
32
  type: 'droplist',
33
33
  values: [
34
34
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -35,7 +35,7 @@
35
35
  required: true,
36
36
  baseName: "imap"
37
37
  },
38
- { name: 'selector', optionName: 'selector', title: 'IAMP Settings Selection',
38
+ { name: 'selector', optionName: 'selector', title: 'IMAP Settings Selection',
39
39
  type: 'droplist',
40
40
  values: [
41
41
  {title: 'Use ENV ', value: 'ENV' ,show:[],hide:['imap_msg','imap_host','imap_user','imap_password','imap_port','imap_tls']},
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
- {
9
- public function imapcount($options, $name) {
10
-
11
- $myObj->response = "This function is not yet available in PHP";
12
-
13
- return json_encode($myObj);
14
- }
15
- }
16
-
17
- ?>
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
- {
9
- public function imapcreatefolder($options, $name) {
10
-
11
- $myObj->response = "This function is not yet available in PHP";
12
-
13
- return json_encode($myObj);
14
- }
15
- }
16
-
17
- ?>
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
- {
9
- public function imapdelete($options, $name) {
10
-
11
- $myObj->response = "This function is not yet available in PHP";
12
-
13
- return json_encode($myObj);
14
- }
15
- }
16
-
17
- ?>
@@ -1,17 +0,0 @@
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
- ?>
@@ -1,17 +0,0 @@
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
- ?>
@@ -1,17 +0,0 @@
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
- ?>
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
- {
9
- public function imapflag($options, $name) {
10
-
11
- $myObj->response = "This function is not yet available in PHP";
12
-
13
- return json_encode($myObj);
14
- }
15
- }
16
-
17
- ?>
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
- {
9
- public function imapgetattachments($options, $name) {
10
-
11
- $myObj->response = "This function is not yet available in PHP";
12
-
13
- return json_encode($myObj);
14
- }
15
- }
16
-
17
- ?>
@@ -1,17 +0,0 @@
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
- ?>
@@ -1,17 +0,0 @@
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
- ?>
@@ -1,71 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
-
9
- <?php
10
- public function imapMailHeaders($options, $name) {
11
- $IMAP_HOST = $options['imap_host'] ?? getenv('IMAP_HOST');
12
- $IMAP_PASSWORD = $options['imap_password'] ?? getenv('IMAP_PASSWORD');
13
- $IMAP_USER = $options['imap_usesr'] ?? getenv('IMAP_USER');
14
- $IMAP_PORT = $options['imap_port'] ?? getenv('IMAP_PORT');
15
- $IMAP_TLS = strtolower($options['imap_tls'] ?? getenv('IMAP_TLS')) === 'true';
16
-
17
- $offset = $options['offset'] ?? 0;
18
- $payload = $options['payload'] ?? 25;
19
- $mailbox = $options['mailbox'] ?? 'INBOX';
20
-
21
- $imap = imap_open("{" . $IMAP_HOST . ":" . $IMAP_PORT . ($IMAP_TLS ? "/ssl" : "") . "}INBOX", $IMAP_USER, $IMAP_PASSWORD);
22
-
23
- if (!$imap) {
24
- return ['data' => [], 'status' => 401];
25
- }
26
-
27
- $messages = [];
28
- $totalMessages = imap_num_msg($imap);
29
-
30
- if ($totalMessages === 0) {
31
- imap_close($imap);
32
- return ['data' => [], 'status' => 200];
33
- }
34
-
35
- $end = max($totalMessages - ($offset * $payload), 1);
36
- $start = max($end - $payload, 1);
37
-
38
- if ($start > $end || $start < 1) {
39
- imap_close($imap);
40
- return ['data' => [], 'status' => 400];
41
- }
42
-
43
- for ($i = $start; $i <= $end; $i++) {
44
- $headers = imap_headerinfo($imap, $i);
45
- $messageData = [
46
- 'id' => $i,
47
- 'uid' => imap_uid($imap, $i),
48
- 'headers' => [
49
- 'from' => $headers->fromaddress,
50
- 'to' => $headers->toaddress ?? '',
51
- 'cc' => $headers->ccaddress ?? '',
52
- 'bcc' => $headers->bccaddress ?? '',
53
- 'subject' => $headers->subject,
54
- 'message-id' => $headers->message_id ?? '',
55
- 'messagedate' => date('Y-m-d H:i:s', strtotime($headers->date))
56
- ],
57
- 'flags' => imap_fetch_overview($imap, $i)[0]->flags ?? [],
58
- 'attachmentCount' => count(imap_mime_header_decode($headers->subject)),
59
- 'uidvalidity' => imap_uid($imap, $i),
60
- 'mailbox' => $mailbox
61
- ];
62
-
63
- $messages[] = $messageData;
64
- }
65
-
66
- imap_close($imap);
67
- return ['data' => array_reverse($messages), 'status' => 200];
68
- }
69
- ?>
70
-
71
-
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
- {
9
- public function imapmovefolder($options, $name) {
10
-
11
- $myObj->response = "This function is not yet available in PHP";
12
-
13
- return json_encode($myObj);
14
- }
15
- }
16
-
17
- ?>
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
- {
9
- public function imapremoveflag($options, $name) {
10
-
11
- $myObj->response = "This function is not yet available in PHP";
12
-
13
- return json_encode($myObj);
14
- }
15
- }
16
-
17
- ?>
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
- {
9
- public function imapsaveflag($options, $name) {
10
-
11
- $myObj->response = "This function is not yet available in PHP";
12
-
13
- return json_encode($myObj);
14
- }
15
- }
16
-
17
- ?>
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
- {
9
- public function imapsendmail($options, $name) {
10
-
11
- $myObj->response = "This function is not yet available in PHP";
12
-
13
- return json_encode($myObj);
14
- }
15
- }
16
-
17
- ?>
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
- {
9
- public function imapstore($options, $name) {
10
-
11
- $myObj->response = "This function is not yet available in PHP";
12
-
13
- return json_encode($myObj);
14
- }
15
- }
16
-
17
- ?>
@@ -1,17 +0,0 @@
1
- <?php
2
-
3
- namespace modules;
4
-
5
- use \lib\core\Module;
6
-
7
- class custom extends Module
8
- {
9
- public function imapsubscribe($options, $name) {
10
-
11
- $myObj->response = "This function is not yet available in PHP";
12
-
13
- return json_encode($myObj);
14
- }
15
- }
16
-
17
- ?>
@@ -1,17 +0,0 @@
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
- ?>
@@ -1,17 +0,0 @@
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
- ?>
@@ -1,17 +0,0 @@
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
- ?>