n8n-nodes-postmark-smtp 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -13,7 +13,6 @@ This is an n8n community node. It lets you use Postmark to send transactional em
13
13
  - Attachments (binary data).
14
14
  - CC and BCC recipients.
15
15
  - Dynamic sender verification (loads verified domains from your account).
16
- - **Send Email with Template**: Use Postmark's template feature to send emails with full sender/recipient control.
17
16
 
18
17
  ## Credentials
19
18
 
@@ -37,30 +36,15 @@ docker exec -it n8n npm install n8n-nodes-postmark-smtp
37
36
  ## Usage
38
37
 
39
38
  ### Sending an Email
40
- 1. Select the **Send Email** operation.
41
- 2. Connect your **Postmark API** credential (fill in Server Token and optionally Account Token).
42
- 3. Select a valid **From Domain** (dynamically loaded).
43
- 4. (Optional) Enter **From Name**.
44
- 5. Enter **From Email**. *Note: This must belong to the selected 'From Domain' or the node will error.*
45
- 6. (Optional) Enter **To Name**.
46
- 7. Enter **To Email**.
47
- 8. Fill in *Subject*, *HTML Body*, and *Text Body*.
48
-
49
- ### Sending with Templates
50
- 1. Select the **Send Email with Template** operation.
51
- 2. Connect your **Postmark API** credential.
52
- 3. Select a valid **From Domain**.
53
- 4. Enter **From Name** and **From Email**.
54
- 5. Enter **To Name** and **To Email**.
55
- 6. Enter the **Template ID** (found in Postmark UI).
56
- 7. Provide the **Template Model** as a JSON object matching your template variables.
57
- ```json
58
- {
59
- "user_name": "John Doe",
60
- "action_url": "https://example.com/login"
61
- }
62
- ```
63
- 8. (Optional) Add **Attachments**.
39
+ 1. Connect your **Postmark API** credential (fill in Server Token and optionally Account Token).
40
+ 2. Select a valid **From Domain** (dynamically loaded).
41
+ 3. (Optional) Enter **From Name**.
42
+ 4. Enter **From Email**. *Note: This must belong to the selected 'From Domain' or the node will error.*
43
+ 5. (Optional) Enter **To Name**.
44
+ 6. Enter **To Email**.
45
+ 7. (Optional) Enter **Cc** and **Bcc**.
46
+ 8. Fill in **Subject**, **HTML Body**, and **Text Body**.
47
+ 9. (Optional) Toggle **Attachments** to add files.
64
48
 
65
49
  ## Development
66
50
 
@@ -9,7 +9,7 @@ class PostmarkSmtp {
9
9
  icon: 'file:postmark.svg',
10
10
  group: ['transform'],
11
11
  version: 1,
12
- subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
12
+ subtitle: 'Send Email',
13
13
  description: 'Send emails via Postmark API',
14
14
  defaults: {
15
15
  name: 'Postmark SMTP',
@@ -23,43 +23,6 @@ class PostmarkSmtp {
23
23
  },
24
24
  ],
25
25
  properties: [
26
- {
27
- displayName: 'Resource',
28
- name: 'resource',
29
- type: 'options',
30
- noDataExpression: true,
31
- options: [
32
- {
33
- name: 'Email',
34
- value: 'email',
35
- },
36
- ],
37
- default: 'email',
38
- },
39
- {
40
- displayName: 'Operation',
41
- name: 'operation',
42
- type: 'options',
43
- noDataExpression: true,
44
- displayOptions: {
45
- show: {
46
- resource: ['email'],
47
- },
48
- },
49
- options: [
50
- {
51
- name: 'Send Email',
52
- value: 'sendEmail',
53
- action: 'Send an email',
54
- },
55
- {
56
- name: 'Send Email with Template',
57
- value: 'sendEmailWithTemplate',
58
- action: 'Send an email using a template',
59
- },
60
- ],
61
- default: 'sendEmail',
62
- },
63
26
  {
64
27
  displayName: 'From Domain',
65
28
  name: 'fromDomain',
@@ -69,12 +32,6 @@ class PostmarkSmtp {
69
32
  loadOptionsMethod: 'getDomains',
70
33
  },
71
34
  default: '',
72
- displayOptions: {
73
- show: {
74
- operation: ['sendEmail', 'sendEmailWithTemplate'],
75
- resource: ['email'],
76
- },
77
- },
78
35
  description: 'Choose a verified domain',
79
36
  },
80
37
  {
@@ -83,12 +40,6 @@ class PostmarkSmtp {
83
40
  type: 'string',
84
41
  default: '',
85
42
  placeholder: 'Sender Name',
86
- displayOptions: {
87
- show: {
88
- operation: ['sendEmail', 'sendEmailWithTemplate'],
89
- resource: ['email'],
90
- },
91
- },
92
43
  },
93
44
  {
94
45
  displayName: 'From Email',
@@ -97,12 +48,6 @@ class PostmarkSmtp {
97
48
  default: '',
98
49
  placeholder: 'sender@example.com',
99
50
  required: true,
100
- displayOptions: {
101
- show: {
102
- operation: ['sendEmail', 'sendEmailWithTemplate'],
103
- resource: ['email'],
104
- },
105
- },
106
51
  description: 'The sender email address. Must be from the selected domain.',
107
52
  },
108
53
  {
@@ -111,12 +56,6 @@ class PostmarkSmtp {
111
56
  type: 'string',
112
57
  default: '',
113
58
  placeholder: 'Recipient Name',
114
- displayOptions: {
115
- show: {
116
- operation: ['sendEmail', 'sendEmailWithTemplate'],
117
- resource: ['email'],
118
- },
119
- },
120
59
  },
121
60
  {
122
61
  displayName: 'To Email',
@@ -125,26 +64,28 @@ class PostmarkSmtp {
125
64
  default: '',
126
65
  placeholder: 'receiver@example.com',
127
66
  required: true,
128
- displayOptions: {
129
- show: {
130
- operation: ['sendEmail', 'sendEmailWithTemplate'],
131
- resource: ['email'],
132
- },
133
- },
134
67
  description: 'Comma separated list of recipients',
135
68
  },
69
+ {
70
+ displayName: 'Cc',
71
+ name: 'cc',
72
+ type: 'string',
73
+ default: '',
74
+ placeholder: 'cc@example.com',
75
+ },
76
+ {
77
+ displayName: 'Bcc',
78
+ name: 'bcc',
79
+ type: 'string',
80
+ default: '',
81
+ placeholder: 'bcc@example.com',
82
+ },
136
83
  {
137
84
  displayName: 'Subject',
138
85
  name: 'subject',
139
86
  type: 'string',
140
87
  default: '',
141
88
  required: true,
142
- displayOptions: {
143
- show: {
144
- operation: ['sendEmail'],
145
- resource: ['email'],
146
- },
147
- },
148
89
  },
149
90
  {
150
91
  displayName: 'HTML Body',
@@ -154,12 +95,6 @@ class PostmarkSmtp {
154
95
  rows: 5,
155
96
  },
156
97
  default: '',
157
- displayOptions: {
158
- show: {
159
- operation: ['sendEmail'],
160
- resource: ['email'],
161
- },
162
- },
163
98
  },
164
99
  {
165
100
  displayName: 'Text Body',
@@ -169,39 +104,26 @@ class PostmarkSmtp {
169
104
  rows: 5,
170
105
  },
171
106
  default: '',
172
- displayOptions: {
173
- show: {
174
- operation: ['sendEmail'],
175
- resource: ['email'],
176
- },
177
- },
178
107
  },
179
108
  {
180
109
  displayName: 'Attachments',
181
110
  name: 'attachmentsToggle',
182
111
  type: 'boolean',
183
112
  default: false,
184
- displayOptions: {
185
- show: {
186
- operation: ['sendEmail', 'sendEmailWithTemplate'],
187
- resource: ['email'],
188
- },
189
- },
113
+ description: 'Whether to add attachments',
190
114
  },
191
115
  {
192
116
  displayName: 'Attachments',
193
117
  name: 'attachments',
194
118
  type: 'fixedCollection',
195
- typeOptions: {
196
- multipleValues: true,
197
- },
198
119
  displayOptions: {
199
120
  show: {
200
121
  attachmentsToggle: [true],
201
- operation: ['sendEmail', 'sendEmailWithTemplate'],
202
- resource: ['email'],
203
122
  },
204
123
  },
124
+ typeOptions: {
125
+ multipleValues: true,
126
+ },
205
127
  options: [
206
128
  {
207
129
  name: 'attachment',
@@ -226,61 +148,6 @@ class PostmarkSmtp {
226
148
  ],
227
149
  default: {},
228
150
  },
229
- // Additional fields for Send Email
230
- {
231
- displayName: 'Cc',
232
- name: 'cc',
233
- type: 'string',
234
- default: '',
235
- displayOptions: {
236
- show: {
237
- operation: ['sendEmail', 'sendEmailWithTemplate'],
238
- resource: ['email'],
239
- },
240
- },
241
- },
242
- {
243
- displayName: 'Bcc',
244
- name: 'bcc',
245
- type: 'string',
246
- default: '',
247
- displayOptions: {
248
- show: {
249
- operation: ['sendEmail', 'sendEmailWithTemplate'],
250
- resource: ['email'],
251
- },
252
- },
253
- },
254
- // ----------------------------------
255
- // sendEmailWithTemplate
256
- // ----------------------------------
257
- {
258
- displayName: 'Template ID',
259
- name: 'templateId',
260
- type: 'string',
261
- default: '',
262
- required: true,
263
- displayOptions: {
264
- show: {
265
- operation: ['sendEmailWithTemplate'],
266
- resource: ['email'],
267
- },
268
- },
269
- },
270
- {
271
- displayName: 'Template Model',
272
- name: 'templateModel',
273
- type: 'json',
274
- default: '{}',
275
- required: true,
276
- displayOptions: {
277
- show: {
278
- operation: ['sendEmailWithTemplate'],
279
- resource: ['email'],
280
- },
281
- },
282
- description: 'JSON object containing the template model values',
283
- },
284
151
  ],
285
152
  };
286
153
  this.methods = {
@@ -310,156 +177,81 @@ class PostmarkSmtp {
310
177
  async execute() {
311
178
  const items = this.getInputData();
312
179
  const returnData = [];
313
- const operation = this.getNodeParameter('operation', 0);
314
180
  const credentials = await this.getCredentials('postmarkApi');
315
181
  const serverToken = credentials.serverToken;
316
182
  for (let i = 0; i < items.length; i++) {
317
183
  try {
318
- let responseData;
319
- if (operation === 'sendEmail') {
320
- const fromDomain = this.getNodeParameter('fromDomain', i);
321
- const fromName = this.getNodeParameter('fromName', i);
322
- const fromEmail = this.getNodeParameter('fromEmail', i);
323
- if (!fromEmail.toLowerCase().endsWith('@' + fromDomain.toLowerCase())) {
324
- if (this.continueOnFail()) {
325
- returnData.push({
326
- json: {
327
- error: `From Email (${fromEmail}) must belong to the selected domain (${fromDomain})`,
328
- },
329
- });
330
- continue;
331
- }
332
- throw new Error(`From Email (${fromEmail}) must belong to the selected domain (${fromDomain})`);
333
- }
334
- let from = fromEmail;
335
- if (fromName) {
336
- from = `"${fromName}" <${fromEmail}>`;
184
+ const fromDomain = this.getNodeParameter('fromDomain', i);
185
+ const fromName = this.getNodeParameter('fromName', i);
186
+ const fromEmail = this.getNodeParameter('fromEmail', i);
187
+ if (!fromEmail.toLowerCase().endsWith('@' + fromDomain.toLowerCase())) {
188
+ if (this.continueOnFail()) {
189
+ returnData.push({
190
+ json: {
191
+ error: `From Email (${fromEmail}) must belong to the selected domain (${fromDomain})`,
192
+ },
193
+ });
194
+ continue;
337
195
  }
338
- const toName = this.getNodeParameter('toName', i);
339
- const toEmail = this.getNodeParameter('toEmail', i);
340
- let to = toEmail;
341
- if (toName) {
342
- to = `"${toName}" <${toEmail}>`;
343
- }
344
- const subject = this.getNodeParameter('subject', i);
345
- const htmlBody = this.getNodeParameter('htmlBody', i);
346
- const textBody = this.getNodeParameter('textBody', i);
347
- const cc = this.getNodeParameter('cc', i);
348
- const bcc = this.getNodeParameter('bcc', i);
349
- const body = {
350
- From: from,
351
- To: to,
352
- Subject: subject,
353
- HtmlBody: htmlBody,
354
- TextBody: textBody,
355
- Cc: cc,
356
- Bcc: bcc,
357
- MessageStream: 'outbound',
358
- };
359
- // Handle Attachments
360
- const attachmentsToggle = this.getNodeParameter('attachmentsToggle', i);
361
- if (attachmentsToggle) {
362
- const attachmentsConfig = this.getNodeParameter('attachments', i);
363
- const attachments = [];
364
- if (attachmentsConfig && attachmentsConfig.attachment) {
365
- for (const att of attachmentsConfig.attachment) {
366
- const propertyName = att.propertyName;
367
- const binaryData = this.helpers.assertBinaryData(i, propertyName);
368
- const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyName);
369
- attachments.push({
370
- Name: att.fileName || binaryData.fileName || 'attachment',
371
- Content: binaryDataBuffer.toString('base64'),
372
- ContentType: binaryData.mimeType,
373
- });
374
- }
375
- }
376
- if (attachments.length > 0) {
377
- body.Attachments = attachments;
378
- }
379
- }
380
- const options = {
381
- method: 'POST',
382
- uri: 'https://api.postmarkapp.com/email',
383
- headers: {
384
- 'X-Postmark-Server-Token': serverToken,
385
- 'Accept': 'application/json',
386
- },
387
- body: body,
388
- json: true,
389
- };
390
- responseData = await this.helpers.request(options);
196
+ throw new Error(`From Email (${fromEmail}) must belong to the selected domain (${fromDomain})`);
391
197
  }
392
- else if (operation === 'sendEmailWithTemplate') {
393
- const fromDomain = this.getNodeParameter('fromDomain', i);
394
- const fromName = this.getNodeParameter('fromName', i);
395
- const fromEmail = this.getNodeParameter('fromEmail', i);
396
- if (!fromEmail.toLowerCase().endsWith('@' + fromDomain.toLowerCase())) {
397
- if (this.continueOnFail()) {
398
- returnData.push({
399
- json: {
400
- error: `From Email (${fromEmail}) must belong to the selected domain (${fromDomain})`,
401
- },
198
+ let from = fromEmail;
199
+ if (fromName) {
200
+ from = `"${fromName}" <${fromEmail}>`;
201
+ }
202
+ const toName = this.getNodeParameter('toName', i);
203
+ const toEmail = this.getNodeParameter('toEmail', i);
204
+ let to = toEmail;
205
+ if (toName) {
206
+ to = `"${toName}" <${toEmail}>`;
207
+ }
208
+ const cc = this.getNodeParameter('cc', i);
209
+ const bcc = this.getNodeParameter('bcc', i);
210
+ const subject = this.getNodeParameter('subject', i);
211
+ const htmlBody = this.getNodeParameter('htmlBody', i);
212
+ const textBody = this.getNodeParameter('textBody', i);
213
+ const body = {
214
+ From: from,
215
+ To: to,
216
+ Subject: subject,
217
+ HtmlBody: htmlBody,
218
+ TextBody: textBody,
219
+ Cc: cc,
220
+ Bcc: bcc,
221
+ MessageStream: 'outbound',
222
+ };
223
+ // Handle Attachments
224
+ const attachmentsToggle = this.getNodeParameter('attachmentsToggle', i);
225
+ if (attachmentsToggle) {
226
+ const attachmentsConfig = this.getNodeParameter('attachments', i);
227
+ const attachments = [];
228
+ if (attachmentsConfig && attachmentsConfig.attachment) {
229
+ for (const att of attachmentsConfig.attachment) {
230
+ const propertyName = att.propertyName;
231
+ const binaryData = this.helpers.assertBinaryData(i, propertyName);
232
+ const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyName);
233
+ attachments.push({
234
+ Name: att.fileName || binaryData.fileName || 'attachment',
235
+ Content: binaryDataBuffer.toString('base64'),
236
+ ContentType: binaryData.mimeType,
402
237
  });
403
- continue;
404
238
  }
405
- throw new Error(`From Email (${fromEmail}) must belong to the selected domain (${fromDomain})`);
406
239
  }
407
- let from = fromEmail;
408
- if (fromName) {
409
- from = `"${fromName}" <${fromEmail}>`;
240
+ if (attachments.length > 0) {
241
+ body.Attachments = attachments;
410
242
  }
411
- const toName = this.getNodeParameter('toName', i);
412
- const toEmail = this.getNodeParameter('toEmail', i);
413
- let to = toEmail;
414
- if (toName) {
415
- to = `"${toName}" <${toEmail}>`;
416
- }
417
- const templateId = this.getNodeParameter('templateId', i);
418
- const templateModel = this.getNodeParameter('templateModel', i);
419
- const cc = this.getNodeParameter('cc', i);
420
- const bcc = this.getNodeParameter('bcc', i);
421
- const body = {
422
- From: from,
423
- To: to,
424
- TemplateId: templateId,
425
- TemplateModel: templateModel,
426
- Cc: cc,
427
- Bcc: bcc,
428
- MessageStream: 'outbound',
429
- };
430
- // Handle Attachments
431
- const attachmentsToggle = this.getNodeParameter('attachmentsToggle', i);
432
- if (attachmentsToggle) {
433
- const attachmentsConfig = this.getNodeParameter('attachments', i);
434
- const attachments = [];
435
- if (attachmentsConfig && attachmentsConfig.attachment) {
436
- for (const att of attachmentsConfig.attachment) {
437
- const propertyName = att.propertyName;
438
- const binaryData = this.helpers.assertBinaryData(i, propertyName);
439
- const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyName);
440
- attachments.push({
441
- Name: att.fileName || binaryData.fileName || 'attachment',
442
- Content: binaryDataBuffer.toString('base64'),
443
- ContentType: binaryData.mimeType,
444
- });
445
- }
446
- }
447
- if (attachments.length > 0) {
448
- body.Attachments = attachments;
449
- }
450
- }
451
- const options = {
452
- method: 'POST',
453
- uri: 'https://api.postmarkapp.com/email/withTemplate',
454
- headers: {
455
- 'X-Postmark-Server-Token': serverToken,
456
- 'Accept': 'application/json',
457
- },
458
- body: body,
459
- json: true,
460
- };
461
- responseData = await this.helpers.request(options);
462
243
  }
244
+ const options = {
245
+ method: 'POST',
246
+ uri: 'https://api.postmarkapp.com/email',
247
+ headers: {
248
+ 'X-Postmark-Server-Token': serverToken,
249
+ 'Accept': 'application/json',
250
+ },
251
+ body: body,
252
+ json: true,
253
+ };
254
+ const responseData = await this.helpers.request(options);
463
255
  returnData.push({
464
256
  json: responseData,
465
257
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-postmark-smtp",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Postmark SMTP node for n8n",
5
5
  "keywords": [
6
6
  "n8n-community-node-package"