n8n-nodes-postmark-smtp 0.1.3 → 0.1.5

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',
@@ -52,11 +52,6 @@ class PostmarkSmtp {
52
52
  value: 'sendEmail',
53
53
  action: 'Send an email',
54
54
  },
55
- {
56
- name: 'Send Email with Template',
57
- value: 'sendEmailWithTemplate',
58
- action: 'Send an email using a template',
59
- },
60
55
  ],
61
56
  default: 'sendEmail',
62
57
  },
@@ -69,12 +64,6 @@ class PostmarkSmtp {
69
64
  loadOptionsMethod: 'getDomains',
70
65
  },
71
66
  default: '',
72
- displayOptions: {
73
- show: {
74
- operation: ['sendEmail', 'sendEmailWithTemplate'],
75
- resource: ['email'],
76
- },
77
- },
78
67
  description: 'Choose a verified domain',
79
68
  },
80
69
  {
@@ -83,12 +72,6 @@ class PostmarkSmtp {
83
72
  type: 'string',
84
73
  default: '',
85
74
  placeholder: 'Sender Name',
86
- displayOptions: {
87
- show: {
88
- operation: ['sendEmail', 'sendEmailWithTemplate'],
89
- resource: ['email'],
90
- },
91
- },
92
75
  },
93
76
  {
94
77
  displayName: 'From Email',
@@ -97,12 +80,6 @@ class PostmarkSmtp {
97
80
  default: '',
98
81
  placeholder: 'sender@example.com',
99
82
  required: true,
100
- displayOptions: {
101
- show: {
102
- operation: ['sendEmail', 'sendEmailWithTemplate'],
103
- resource: ['email'],
104
- },
105
- },
106
83
  description: 'The sender email address. Must be from the selected domain.',
107
84
  },
108
85
  {
@@ -111,12 +88,6 @@ class PostmarkSmtp {
111
88
  type: 'string',
112
89
  default: '',
113
90
  placeholder: 'Recipient Name',
114
- displayOptions: {
115
- show: {
116
- operation: ['sendEmail', 'sendEmailWithTemplate'],
117
- resource: ['email'],
118
- },
119
- },
120
91
  },
121
92
  {
122
93
  displayName: 'To Email',
@@ -125,26 +96,28 @@ class PostmarkSmtp {
125
96
  default: '',
126
97
  placeholder: 'receiver@example.com',
127
98
  required: true,
128
- displayOptions: {
129
- show: {
130
- operation: ['sendEmail', 'sendEmailWithTemplate'],
131
- resource: ['email'],
132
- },
133
- },
134
99
  description: 'Comma separated list of recipients',
135
100
  },
101
+ {
102
+ displayName: 'Cc',
103
+ name: 'cc',
104
+ type: 'string',
105
+ default: '',
106
+ placeholder: 'cc@example.com',
107
+ },
108
+ {
109
+ displayName: 'Bcc',
110
+ name: 'bcc',
111
+ type: 'string',
112
+ default: '',
113
+ placeholder: 'bcc@example.com',
114
+ },
136
115
  {
137
116
  displayName: 'Subject',
138
117
  name: 'subject',
139
118
  type: 'string',
140
119
  default: '',
141
120
  required: true,
142
- displayOptions: {
143
- show: {
144
- operation: ['sendEmail'],
145
- resource: ['email'],
146
- },
147
- },
148
121
  },
149
122
  {
150
123
  displayName: 'HTML Body',
@@ -154,12 +127,6 @@ class PostmarkSmtp {
154
127
  rows: 5,
155
128
  },
156
129
  default: '',
157
- displayOptions: {
158
- show: {
159
- operation: ['sendEmail'],
160
- resource: ['email'],
161
- },
162
- },
163
130
  },
164
131
  {
165
132
  displayName: 'Text Body',
@@ -169,39 +136,26 @@ class PostmarkSmtp {
169
136
  rows: 5,
170
137
  },
171
138
  default: '',
172
- displayOptions: {
173
- show: {
174
- operation: ['sendEmail'],
175
- resource: ['email'],
176
- },
177
- },
178
139
  },
179
140
  {
180
141
  displayName: 'Attachments',
181
142
  name: 'attachmentsToggle',
182
143
  type: 'boolean',
183
144
  default: false,
184
- displayOptions: {
185
- show: {
186
- operation: ['sendEmail', 'sendEmailWithTemplate'],
187
- resource: ['email'],
188
- },
189
- },
145
+ description: 'Whether to add attachments',
190
146
  },
191
147
  {
192
148
  displayName: 'Attachments',
193
149
  name: 'attachments',
194
150
  type: 'fixedCollection',
195
- typeOptions: {
196
- multipleValues: true,
197
- },
198
151
  displayOptions: {
199
152
  show: {
200
153
  attachmentsToggle: [true],
201
- operation: ['sendEmail', 'sendEmailWithTemplate'],
202
- resource: ['email'],
203
154
  },
204
155
  },
156
+ typeOptions: {
157
+ multipleValues: true,
158
+ },
205
159
  options: [
206
160
  {
207
161
  name: 'attachment',
@@ -226,61 +180,6 @@ class PostmarkSmtp {
226
180
  ],
227
181
  default: {},
228
182
  },
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
183
  ],
285
184
  };
286
185
  this.methods = {
@@ -310,156 +209,81 @@ class PostmarkSmtp {
310
209
  async execute() {
311
210
  const items = this.getInputData();
312
211
  const returnData = [];
313
- const operation = this.getNodeParameter('operation', 0);
314
212
  const credentials = await this.getCredentials('postmarkApi');
315
213
  const serverToken = credentials.serverToken;
316
214
  for (let i = 0; i < items.length; i++) {
317
215
  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}>`;
337
- }
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}>`;
216
+ const fromDomain = this.getNodeParameter('fromDomain', i);
217
+ const fromName = this.getNodeParameter('fromName', i);
218
+ const fromEmail = this.getNodeParameter('fromEmail', i);
219
+ if (!fromEmail.toLowerCase().endsWith('@' + fromDomain.toLowerCase())) {
220
+ if (this.continueOnFail()) {
221
+ returnData.push({
222
+ json: {
223
+ error: `From Email (${fromEmail}) must belong to the selected domain (${fromDomain})`,
224
+ },
225
+ });
226
+ continue;
343
227
  }
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);
228
+ throw new Error(`From Email (${fromEmail}) must belong to the selected domain (${fromDomain})`);
391
229
  }
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
- },
230
+ let from = fromEmail;
231
+ if (fromName) {
232
+ from = `"${fromName}" <${fromEmail}>`;
233
+ }
234
+ const toName = this.getNodeParameter('toName', i);
235
+ const toEmail = this.getNodeParameter('toEmail', i);
236
+ let to = toEmail;
237
+ if (toName) {
238
+ to = `"${toName}" <${toEmail}>`;
239
+ }
240
+ const cc = this.getNodeParameter('cc', i);
241
+ const bcc = this.getNodeParameter('bcc', i);
242
+ const subject = this.getNodeParameter('subject', i);
243
+ const htmlBody = this.getNodeParameter('htmlBody', i);
244
+ const textBody = this.getNodeParameter('textBody', i);
245
+ const body = {
246
+ From: from,
247
+ To: to,
248
+ Subject: subject,
249
+ HtmlBody: htmlBody,
250
+ TextBody: textBody,
251
+ Cc: cc,
252
+ Bcc: bcc,
253
+ MessageStream: 'outbound',
254
+ };
255
+ // Handle Attachments
256
+ const attachmentsToggle = this.getNodeParameter('attachmentsToggle', i);
257
+ if (attachmentsToggle) {
258
+ const attachmentsConfig = this.getNodeParameter('attachments', i);
259
+ const attachments = [];
260
+ if (attachmentsConfig && attachmentsConfig.attachment) {
261
+ for (const att of attachmentsConfig.attachment) {
262
+ const propertyName = att.propertyName;
263
+ const binaryData = this.helpers.assertBinaryData(i, propertyName);
264
+ const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyName);
265
+ attachments.push({
266
+ Name: att.fileName || binaryData.fileName || 'attachment',
267
+ Content: binaryDataBuffer.toString('base64'),
268
+ ContentType: binaryData.mimeType,
402
269
  });
403
- continue;
404
270
  }
405
- throw new Error(`From Email (${fromEmail}) must belong to the selected domain (${fromDomain})`);
406
271
  }
407
- let from = fromEmail;
408
- if (fromName) {
409
- from = `"${fromName}" <${fromEmail}>`;
272
+ if (attachments.length > 0) {
273
+ body.Attachments = attachments;
410
274
  }
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
275
  }
276
+ const options = {
277
+ method: 'POST',
278
+ uri: 'https://api.postmarkapp.com/email',
279
+ headers: {
280
+ 'X-Postmark-Server-Token': serverToken,
281
+ 'Accept': 'application/json',
282
+ },
283
+ body: body,
284
+ json: true,
285
+ };
286
+ const responseData = await this.helpers.request(options);
463
287
  returnData.push({
464
288
  json: responseData,
465
289
  });
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.5",
4
4
  "description": "Postmark SMTP node for n8n",
5
5
  "keywords": [
6
6
  "n8n-community-node-package"