emailengine-app 2.84.2 → 2.86.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/.ncurc.js +29 -9
- package/.prettierignore +5 -1
- package/.prettierrc.js +2 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +107 -0
- package/Dockerfile +20 -1
- package/ENVIRONMENT.md +139 -0
- package/README.md +2 -2
- package/bin/emailengine.js +434 -408
- package/config/default.toml +2 -0
- package/copy-static-files.sh +41 -14
- package/data/google-crawlers.json +1 -1
- package/data/public_suffix_list.dat +16563 -0
- package/eslint.config.js +81 -99
- package/lib/account-assignment.js +19 -0
- package/lib/account.js +230 -170
- package/lib/api-error-codes.js +49 -0
- package/lib/api-reference/format.js +4 -3
- package/lib/api-reference/model.js +6 -1
- package/lib/api-routes/account-routes.js +255 -38
- package/lib/api-routes/blocklist-routes.js +91 -4
- package/lib/api-routes/delivery-test-routes.js +27 -4
- package/lib/api-routes/export-routes.js +28 -2
- package/lib/api-routes/gateway-routes.js +110 -12
- package/lib/api-routes/index.js +4 -0
- package/lib/api-routes/license-routes.js +2 -2
- package/lib/api-routes/mailbox-routes.js +44 -5
- package/lib/api-routes/message-routes.js +112 -10
- package/lib/api-routes/oauth2-app-routes.js +63 -23
- package/lib/api-routes/outbox-routes.js +97 -52
- package/lib/api-routes/permission-map.js +67 -7
- package/lib/api-routes/scoped-routes.js +74 -0
- package/lib/api-routes/settings-routes.js +34 -6
- package/lib/api-routes/stats-routes.js +5 -1
- package/lib/api-routes/submit-routes.js +337 -309
- package/lib/api-routes/template-routes.js +45 -8
- package/lib/api-routes/token-routes.js +152 -100
- package/lib/api-routes/webhook-delivery-routes.js +262 -0
- package/lib/api-routes/webhook-route-routes.js +132 -6
- package/lib/bounce-detect.js +397 -205
- package/lib/calendar-event.js +81 -1
- package/lib/consts.js +38 -45
- package/lib/db.js +14 -6
- package/lib/delivery-error.js +6 -0
- package/lib/deprecations.js +270 -0
- package/lib/email-client/base-client.js +137 -184
- package/lib/email-client/fallback-poll.js +62 -0
- package/lib/email-client/gmail-client.js +60 -22
- package/lib/email-client/imap/adaptive-idle-store.js +73 -0
- package/lib/email-client/imap/adaptive-idle.js +278 -0
- package/lib/email-client/imap/connection-errors.js +14 -1
- package/lib/email-client/imap/idle-settings.js +31 -5
- package/lib/email-client/imap/listing-diff.js +37 -0
- package/lib/email-client/imap/mailbox.js +372 -242
- package/lib/email-client/imap/subconnection.js +8 -30
- package/lib/email-client/imap/sync-operations.js +220 -127
- package/lib/email-client/imap-client.js +228 -164
- package/lib/email-client/message-builder.js +14 -79
- package/lib/email-client/notification-handler.js +1 -2
- package/lib/email-client/outlook-client.js +372 -338
- package/lib/email-client/smtp-pool-manager.js +16 -13
- package/lib/email-client/sync-state-fields.js +19 -0
- package/lib/encrypt.js +157 -41
- package/lib/enum-descriptions.js +3 -1
- package/lib/env-setting-overrides.js +288 -0
- package/lib/export-worker.js +751 -0
- package/lib/export.js +64 -15
- package/lib/gateway.js +19 -4
- package/lib/get-raw-email.js +25 -107
- package/lib/hapi-request-logger.js +107 -0
- package/lib/health.js +75 -0
- package/lib/imapproxy/imap-core/README.md +6 -5
- package/lib/lock-run.js +119 -0
- package/lib/logger-consts.js +48 -0
- package/lib/logger.js +1 -1
- package/lib/lua/z-head-scores.lua +28 -0
- package/lib/mcp/tools.js +37 -8
- package/lib/network-errors.js +1 -1
- package/lib/node-version.js +24 -0
- package/lib/notify-attachments.js +36 -0
- package/lib/oauth/outlook-mailbox.js +35 -0
- package/lib/oauth/state.js +24 -0
- package/lib/oauth2-apps.js +631 -656
- package/lib/outbox.js +184 -54
- package/lib/parse-message.js +3 -3
- package/lib/pbkdf2-phc.js +1 -1
- package/lib/privileged-settings.js +2 -2
- package/lib/queue-browser/definitions.js +11 -0
- package/lib/queue-browser/index.js +68 -19
- package/lib/queue-job-actions.js +18 -1
- package/lib/queue-retention.js +48 -12
- package/lib/queue-stats.js +11 -2
- package/lib/read-env-value.js +3 -0
- package/lib/redis-memory-warnings.js +99 -0
- package/lib/redis-reconnect.js +29 -0
- package/lib/request-timing.js +23 -0
- package/lib/respawn-backoff.js +35 -0
- package/lib/rewrite-text-nodes.js +19 -59
- package/lib/schemas.js +164 -40
- package/lib/settings.js +6 -2
- package/lib/smtp-auth.js +19 -1
- package/lib/sso.js +1 -1
- package/lib/swagger-options.js +1 -1
- package/lib/thread-diagnostics.js +63 -0
- package/lib/timezones.js +109 -0
- package/lib/tls/provision.js +6 -3
- package/lib/token-audit-log.js +19 -20
- package/lib/token-permission-view.js +7 -6
- package/lib/tools.js +48 -51
- package/lib/totp.js +2 -5
- package/lib/translations.js +1 -2
- package/lib/ui-routes/account-routes.js +475 -454
- package/lib/ui-routes/account-setup.js +99 -0
- package/lib/ui-routes/admin-config-routes.js +152 -100
- package/lib/ui-routes/admin-entities-routes.js +93 -21
- package/lib/ui-routes/auth-routes.js +90 -38
- package/lib/ui-routes/imap-idle-field.js +1 -1
- package/lib/ui-routes/internals-routes.js +5 -0
- package/lib/ui-routes/oauth-config-routes.js +124 -82
- package/lib/ui-routes/outlook-subscription-view.js +1 -1
- package/lib/ui-routes/overridable-fields.js +84 -0
- package/lib/ui-routes/queue-routes.js +8 -5
- package/lib/ui-routes/route-helpers.js +19 -3
- package/lib/ui-routes/settings-page.js +6 -0
- package/lib/ui-routes/tls-config-routes.js +58 -15
- package/lib/utils/back-off.js +82 -0
- package/lib/utils/decode-headers.js +3 -12
- package/lib/utils/filter-empty.js +20 -0
- package/lib/utils/int-setting.js +48 -0
- package/lib/utils/murmurhash3.js +66 -0
- package/lib/utils/public-suffix.js +122 -0
- package/lib/utils/random-id.js +26 -0
- package/lib/utils/tracking-settings.js +35 -0
- package/lib/utils/version.js +74 -0
- package/lib/web-safe-html.js +18 -105
- package/lib/webhook-delivery.js +461 -0
- package/lib/webhook-failures.js +132 -0
- package/lib/webhook-request.js +29 -1
- package/lib/webhook-routing.js +56 -0
- package/lib/webhook-test.js +88 -0
- package/lib/webhooks.js +93 -45
- package/lib/worker-rpc-error.js +2 -1
- package/package.json +37 -38
- package/sbom.json +7902 -1
- package/server.js +784 -518
- package/static/js/ace/ace.js +1 -1
- package/static/licenses.html +225 -1060
- package/translations/messages.pot +62 -63
- package/views/config/ai.hbs +1 -1
- package/views/config/security.hbs +24 -2
- package/views/config/service.hbs +47 -0
- package/views/config/webhooks.hbs +36 -0
- package/views/internals/index.hbs +8 -0
- package/views/partials/queue_retention_note.hbs +12 -8
- package/views/partials/ui/env-managed-alert.hbs +16 -7
- package/views/partials/webhook_form.hbs +1 -1
- package/views/suppression-lists/index.hbs +1 -1
- package/workers/api.js +840 -611
- package/workers/export.js +17 -632
- package/workers/imap.js +13 -0
- package/workers/smtp.js +9 -11
- package/workers/submit.js +1 -1
- package/workers/webhooks.js +18 -448
- package/lib/email-client/outlook-fallback-poll.js +0 -30
|
@@ -91,12 +91,317 @@ const idempotencyResponseSchema = Joi.object({
|
|
|
91
91
|
.example('MISS')
|
|
92
92
|
.description('Whether this response was produced now or replayed from the idempotency cache')
|
|
93
93
|
.meta({ enumDescriptions: ENUM_DESCRIPTIONS.idempotencyStatus })
|
|
94
|
+
.label('ResponseIdempotencyStatus')
|
|
94
95
|
})
|
|
95
96
|
.description('Idempotency info, present when an Idempotency-Key header was used')
|
|
96
97
|
.label('ResponseIdempotency');
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
function buildSubmitMessagePayloadSchema(MAX_ATTACHMENT_SIZE) {
|
|
100
|
+
return Joi.object({
|
|
101
|
+
reference: messageReferenceSchema,
|
|
102
|
+
|
|
103
|
+
envelope: Joi.object({
|
|
104
|
+
from: mailboxAddressSchema.allow('').example('sender@example.com'),
|
|
105
|
+
to: Joi.array().items(mailboxAddressSchema.required().example('recipient@example.com')).single().label('SmtpEnvelopeTo')
|
|
106
|
+
})
|
|
107
|
+
.description('An optional object specifying the SMTP envelope used during email transmission')
|
|
108
|
+
.meta({ usage: FIELD_USAGE.messageEnvelope })
|
|
109
|
+
.label('SMTPEnvelope')
|
|
110
|
+
.when('mailMerge', {
|
|
111
|
+
is: Joi.exist().not(false, null),
|
|
112
|
+
then: Joi.forbidden('y')
|
|
113
|
+
}),
|
|
114
|
+
|
|
115
|
+
raw: Joi.string()
|
|
116
|
+
.base64()
|
|
117
|
+
.max(MAX_ATTACHMENT_SIZE)
|
|
118
|
+
.example('TUlNRS1WZXJzaW9uOiAxLjANClN1YmplY3Q6IGhlbGxvIHdvcmxkDQoNCkhlbGxvIQ0K')
|
|
119
|
+
.description('A Base64-encoded email message in RFC 822 format')
|
|
120
|
+
.meta({ usage: FIELD_USAGE.messageRaw })
|
|
121
|
+
.label('RFC822Raw')
|
|
122
|
+
.when('mailMerge', {
|
|
123
|
+
is: Joi.exist().not(false, null),
|
|
124
|
+
then: Joi.forbidden('y')
|
|
125
|
+
}),
|
|
126
|
+
|
|
127
|
+
from: fromAddressSchema,
|
|
128
|
+
|
|
129
|
+
replyTo: Joi.array()
|
|
130
|
+
.items(addressSchema.label('ReplyToAddress'))
|
|
131
|
+
.single()
|
|
132
|
+
.example([{ name: 'From Me', address: 'sender@example.com' }])
|
|
133
|
+
.description('List of Reply-To addresses')
|
|
134
|
+
.label('ReplyTo'),
|
|
135
|
+
|
|
136
|
+
to: Joi.array()
|
|
137
|
+
.items(addressSchema.label('ToAddress'))
|
|
138
|
+
.single()
|
|
139
|
+
.example([{ address: 'recipient@example.com' }])
|
|
140
|
+
.description('List of recipient addresses')
|
|
141
|
+
.label('ToAddressList')
|
|
142
|
+
.when('mailMerge', {
|
|
143
|
+
is: Joi.exist().not(false, null),
|
|
144
|
+
then: Joi.forbidden('y')
|
|
145
|
+
}),
|
|
146
|
+
|
|
147
|
+
cc: Joi.array()
|
|
148
|
+
.items(addressSchema.label('CcAddress'))
|
|
149
|
+
.single()
|
|
150
|
+
.description('List of CC addresses')
|
|
151
|
+
.label('CcAddressList')
|
|
152
|
+
.when('mailMerge', {
|
|
153
|
+
is: Joi.exist().not(false, null),
|
|
154
|
+
then: Joi.forbidden('y')
|
|
155
|
+
}),
|
|
156
|
+
|
|
157
|
+
bcc: Joi.array()
|
|
158
|
+
.items(addressSchema.label('BccAddress'))
|
|
159
|
+
.single()
|
|
160
|
+
.description('List of BCC addresses')
|
|
161
|
+
.label('BccAddressList')
|
|
162
|
+
.when('mailMerge', {
|
|
163
|
+
is: Joi.exist().not(false, null),
|
|
164
|
+
then: Joi.forbidden('y')
|
|
165
|
+
}),
|
|
166
|
+
|
|
167
|
+
subject: templateSchemas.subject,
|
|
168
|
+
text: templateSchemas.text,
|
|
169
|
+
html: templateSchemas.html,
|
|
170
|
+
previewText: templateSchemas.previewText,
|
|
171
|
+
|
|
172
|
+
template: Joi.string().max(256).example('example').description('Stored template ID to load the email content from'),
|
|
173
|
+
|
|
174
|
+
render: Joi.object({
|
|
175
|
+
format: Joi.string()
|
|
176
|
+
.valid('html', 'markdown')
|
|
177
|
+
.default('html')
|
|
178
|
+
.description('Markup language the template is written in')
|
|
179
|
+
.meta({ enumDescriptions: ENUM_DESCRIPTIONS.renderFormat })
|
|
180
|
+
.label('RenderFormat'),
|
|
181
|
+
params: Joi.object()
|
|
182
|
+
.label('RenderValues')
|
|
183
|
+
.example({ firstName: 'Nyan', orderId: '4815' })
|
|
184
|
+
.description('An object of variables for the template renderer')
|
|
185
|
+
})
|
|
186
|
+
.allow(false)
|
|
187
|
+
.description('Template rendering options. Set to `false` to send the template as-is, without rendering it.')
|
|
188
|
+
.when('mailMerge', {
|
|
189
|
+
is: Joi.exist().not(false, null),
|
|
190
|
+
then: Joi.forbidden('y')
|
|
191
|
+
})
|
|
192
|
+
.label('TemplateRender'),
|
|
193
|
+
|
|
194
|
+
mailMerge: Joi.array()
|
|
195
|
+
.items(
|
|
196
|
+
Joi.object({
|
|
197
|
+
to: addressSchema.label('ToAddress').required(),
|
|
198
|
+
messageId: Joi.string().max(996).example('<test123@example.com>').description('Message ID'),
|
|
199
|
+
params: Joi.object()
|
|
200
|
+
.label('RenderValues')
|
|
201
|
+
.example({ firstName: 'Nyan', orderId: '4815' })
|
|
202
|
+
.description('An object of variables for the template renderer'),
|
|
203
|
+
sendAt: Joi.date()
|
|
204
|
+
.iso()
|
|
205
|
+
.example('2021-07-08T07:06:34.336Z')
|
|
206
|
+
.description('Send message at specified time. Overrides message level `sendAt` value.')
|
|
207
|
+
}).label('MailMergeListEntry')
|
|
208
|
+
)
|
|
209
|
+
.min(1)
|
|
210
|
+
.max(MAX_MAIL_MERGE_ENTRIES)
|
|
211
|
+
.description(`Mail merge options. A separate email is generated for each recipient, up to ${MAX_MAIL_MERGE_ENTRIES} per request`)
|
|
212
|
+
.meta({ usage: FIELD_USAGE.mailMerge })
|
|
213
|
+
.label('MailMergeList'),
|
|
214
|
+
|
|
215
|
+
attachments: Joi.array()
|
|
216
|
+
.items(
|
|
217
|
+
Joi.object({
|
|
218
|
+
filename: Joi.string().max(256).example('transparent.gif'),
|
|
219
|
+
content: Joi.string()
|
|
220
|
+
.base64()
|
|
221
|
+
.max(MAX_ATTACHMENT_SIZE)
|
|
222
|
+
.required()
|
|
223
|
+
.example('R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=')
|
|
224
|
+
.description('Base64 formatted attachment file')
|
|
225
|
+
.when('reference', {
|
|
226
|
+
is: Joi.exist().not(false, null),
|
|
227
|
+
then: Joi.forbidden(),
|
|
228
|
+
otherwise: Joi.required()
|
|
229
|
+
}),
|
|
230
|
+
|
|
231
|
+
contentType: Joi.string().lowercase().max(256).example('image/gif'),
|
|
232
|
+
contentDisposition: Joi.string().lowercase().valid('inline', 'attachment').label('AttachmentContentDisposition'),
|
|
233
|
+
cid: Joi.string().max(256).example('unique-image-id@localhost').description('Content-ID value for embedded images'),
|
|
234
|
+
encoding: Joi.string().valid('base64').default('base64').label('AttachmentEncoding'),
|
|
235
|
+
|
|
236
|
+
reference: Joi.string()
|
|
237
|
+
.base64({ paddingRequired: false, urlSafe: true })
|
|
238
|
+
.max(256)
|
|
239
|
+
.allow(false, null)
|
|
240
|
+
.example('AAAAAQAACnAcde')
|
|
241
|
+
.description('References an existing attachment by its ID instead of providing new attachment content')
|
|
242
|
+
.meta({ usage: FIELD_USAGE.attachmentReference })
|
|
243
|
+
.label('AttachmentReference')
|
|
244
|
+
}).label('SubmitAttachment')
|
|
245
|
+
)
|
|
246
|
+
.max(MAX_MESSAGE_ATTACHMENTS)
|
|
247
|
+
.description('List of attachments')
|
|
248
|
+
.label('SubmitAttachmentList'),
|
|
249
|
+
|
|
250
|
+
messageId: Joi.string().max(996).example('<test123@example.com>').description('Message ID'),
|
|
251
|
+
headers: Joi.object().label('CustomHeaders').description('Custom Headers').unknown().example({
|
|
252
|
+
'X-My-Custom-Header': 'Custom header value'
|
|
253
|
+
}),
|
|
254
|
+
|
|
255
|
+
trackingEnabled: Joi.boolean().example(false).description('Should EmailEngine track clicks and opens for this message').meta({ swaggerHidden: true }),
|
|
256
|
+
|
|
257
|
+
trackOpens: Joi.boolean().example(false).description('Should EmailEngine track opens for this message'),
|
|
258
|
+
trackClicks: Joi.boolean().example(false).description('Should EmailEngine track clicks for this message'),
|
|
259
|
+
|
|
260
|
+
copy: Joi.boolean()
|
|
261
|
+
.allow(null)
|
|
262
|
+
.example(null)
|
|
263
|
+
.description("If set then either copies the message to the Sent Mail folder or not. If not set then uses the account's default setting")
|
|
264
|
+
.meta({ usage: FIELD_USAGE.messageCopy }),
|
|
265
|
+
|
|
266
|
+
sentMailPath: Joi.string()
|
|
267
|
+
.empty('')
|
|
268
|
+
.max(1024)
|
|
269
|
+
.example('Sent Mail')
|
|
270
|
+
.description("Upload sent message to this folder. By default the account's Sent Mail folder is used."),
|
|
271
|
+
|
|
272
|
+
locale: Joi.string().empty('').max(100).example('fr').description('Optional locale').label('MessageLocale'),
|
|
273
|
+
tz: Joi.string().empty('').max(100).example('Europe/Tallinn').description('Optional timezone'),
|
|
274
|
+
|
|
275
|
+
sendAt: sendAtSchema,
|
|
276
|
+
deliveryAttempts: deliveryAttemptsSchema,
|
|
277
|
+
gateway: gatewaySchema,
|
|
278
|
+
|
|
279
|
+
listId: Joi.string()
|
|
280
|
+
.hostname()
|
|
281
|
+
.example('test-list')
|
|
282
|
+
.description('List ID for Mail Merge. Must use a subdomain name format. Lists are registered ad-hoc, so a new identifier defines a new list.')
|
|
283
|
+
.label('ListID')
|
|
284
|
+
.when('mailMerge', {
|
|
285
|
+
is: Joi.exist().not(false, null),
|
|
286
|
+
then: Joi.optional(),
|
|
287
|
+
otherwise: Joi.forbidden()
|
|
288
|
+
}),
|
|
289
|
+
|
|
290
|
+
dsn: dsnSchema.label('DSN'),
|
|
291
|
+
|
|
292
|
+
baseUrl: Joi.string()
|
|
293
|
+
.trim()
|
|
294
|
+
.empty('')
|
|
295
|
+
.uri({
|
|
296
|
+
scheme: ['http', 'https'],
|
|
297
|
+
allowRelative: false
|
|
298
|
+
})
|
|
299
|
+
.example('https://customer123.myservice.com')
|
|
300
|
+
.description('Optional base URL for trackers. This URL must point to your EmailEngine instance.'),
|
|
301
|
+
|
|
302
|
+
proxy: proxySchema,
|
|
303
|
+
localAddress: localAddressSchema,
|
|
304
|
+
|
|
305
|
+
dryRun: apiBoolean()
|
|
306
|
+
.default(false)
|
|
307
|
+
.description(
|
|
308
|
+
'If true, then EmailEngine does not send the email and returns an RFC822 formatted email file. Tracking information is not added to the email.'
|
|
309
|
+
)
|
|
310
|
+
.label('Preview')
|
|
311
|
+
})
|
|
312
|
+
.oxor('raw', 'html')
|
|
313
|
+
.oxor('raw', 'text')
|
|
314
|
+
.oxor('raw', 'text')
|
|
315
|
+
.oxor('raw', 'attachments')
|
|
316
|
+
.label('SubmitMessage')
|
|
317
|
+
.example({
|
|
318
|
+
to: [
|
|
319
|
+
{
|
|
320
|
+
name: 'Nyan Cat',
|
|
321
|
+
address: 'nyan.cat@example.com'
|
|
322
|
+
}
|
|
323
|
+
],
|
|
324
|
+
subject: 'What a wonderful message!',
|
|
325
|
+
text: 'Hello from myself!',
|
|
326
|
+
html: '<p>Hello from myself!</p>',
|
|
327
|
+
attachments: [
|
|
328
|
+
{
|
|
329
|
+
filename: 'transparent.gif',
|
|
330
|
+
content: 'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=',
|
|
331
|
+
contentType: 'image/gif'
|
|
332
|
+
}
|
|
333
|
+
]
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function buildSubmitMessageResponseSchema() {
|
|
338
|
+
return Joi.object({
|
|
339
|
+
response: Joi.string().example('Queued for delivery'),
|
|
340
|
+
messageId: Joi.string()
|
|
341
|
+
.example('<a2184d08-a470-fec6-a493-fa211a3756e9@example.com>')
|
|
342
|
+
.description('Message-ID header value. Not present for bulk messages.'),
|
|
343
|
+
queueId: Joi.string().example('d41f0423195f271f').description('Queue identifier for scheduled email. Not present for bulk messages.'),
|
|
344
|
+
sendAt: Joi.date().example('2021-07-08T07:06:34.336Z').description('Scheduled send time'),
|
|
345
|
+
|
|
346
|
+
reference: Joi.object({
|
|
347
|
+
message: Joi.string()
|
|
348
|
+
.base64({ paddingRequired: false, urlSafe: true })
|
|
349
|
+
.max(256)
|
|
350
|
+
.example('AAAAAQAACnA')
|
|
351
|
+
.description('Referenced message ID. Not present when only a thread ID was referenced'),
|
|
352
|
+
threadId: threadIdSchema.description('Referenced thread ID (Gmail API accounts only)').label('SubmitResponseReferenceThreadId'),
|
|
353
|
+
success: Joi.boolean().example(true).description('Was the referenced message processed successfully').label('ResponseReferenceSuccess'),
|
|
354
|
+
error: Joi.string().example('Referenced message was not found').description('An error message if referenced message processing failed')
|
|
355
|
+
})
|
|
356
|
+
.description('Reference info if referencing was requested')
|
|
357
|
+
.label('SubmitResponseReference'),
|
|
358
|
+
|
|
359
|
+
preview: Joi.string()
|
|
360
|
+
.base64()
|
|
361
|
+
.example('Q29udGVudC1UeXBlOiBtdWx0aX...')
|
|
362
|
+
.description('Base64 encoded RFC822 email if a preview was requested. Not returned for mail-merge submissions.')
|
|
363
|
+
.label('ResponsePreview'),
|
|
364
|
+
|
|
365
|
+
idempotency: idempotencyResponseSchema,
|
|
366
|
+
|
|
367
|
+
mailMerge: Joi.array()
|
|
368
|
+
.items(
|
|
369
|
+
Joi.object({
|
|
370
|
+
success: Joi.boolean().example(true).description('Was the message queued successfully').label('ResponseReferenceSuccess'),
|
|
371
|
+
to: addressSchema.label('ToAddressSingle'),
|
|
372
|
+
messageId: Joi.string().max(996).example('<test123@example.com>').description('Message ID'),
|
|
373
|
+
queueId: Joi.string().example('d41f0423195f271f').description('Queue identifier for the scheduled email'),
|
|
374
|
+
sendAt: Joi.date().iso().example('2021-07-08T07:06:34.336Z').description('Scheduled send time for this recipient'),
|
|
375
|
+
error: Joi.string().example('Failed to queue message').description('Error message if queueing failed for this recipient'),
|
|
376
|
+
code: Joi.string().example('EENVELOPE').description('Error code if queueing failed for this recipient'),
|
|
377
|
+
statusCode: Joi.number().integer().allow(null).example(500).description('Error status code if queueing failed for this recipient'),
|
|
378
|
+
skipped: Joi.object({
|
|
379
|
+
reason: Joi.string().example('unsubscribe').description('Why this message was skipped'),
|
|
380
|
+
listId: Joi.string().example('test-list')
|
|
381
|
+
})
|
|
382
|
+
.description('Info about skipped message. If this value is set, then the message was not sent')
|
|
383
|
+
.label('SkippedMessageInfo')
|
|
384
|
+
})
|
|
385
|
+
.label('BulkResponseEntry')
|
|
386
|
+
.example({
|
|
387
|
+
success: true,
|
|
388
|
+
to: {
|
|
389
|
+
name: 'Andris 2',
|
|
390
|
+
address: 'andris@ethereal.email'
|
|
391
|
+
},
|
|
392
|
+
messageId: '<19b9c433-d428-f6d8-1d00-d666ebcadfc4@ekiri.ee>',
|
|
393
|
+
queueId: '1812477338914c8372a',
|
|
394
|
+
sendAt: '2021-07-08T07:06:34.336Z'
|
|
395
|
+
})
|
|
396
|
+
.unknown()
|
|
397
|
+
)
|
|
398
|
+
.label('BulkResponseList')
|
|
399
|
+
.description('Bulk message responses')
|
|
400
|
+
}).label('SubmitMessageResponse');
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function registerSubmitMessage(server, args) {
|
|
404
|
+
const { call, CORS_CONFIG, MAX_ATTACHMENT_SIZE, MAX_BODY_SIZE, MAX_PAYLOAD_TIMEOUT } = args;
|
|
100
405
|
|
|
101
406
|
server.route({
|
|
102
407
|
method: 'POST',
|
|
@@ -223,320 +528,19 @@ async function init(args) {
|
|
|
223
528
|
|
|
224
529
|
headers: submitHeadersSchema,
|
|
225
530
|
|
|
226
|
-
payload:
|
|
227
|
-
reference: messageReferenceSchema,
|
|
228
|
-
|
|
229
|
-
envelope: Joi.object({
|
|
230
|
-
from: mailboxAddressSchema.allow('').example('sender@example.com'),
|
|
231
|
-
to: Joi.array().items(mailboxAddressSchema.required().example('recipient@example.com')).single().label('SmtpEnvelopeTo')
|
|
232
|
-
})
|
|
233
|
-
.description('An optional object specifying the SMTP envelope used during email transmission')
|
|
234
|
-
.meta({ usage: FIELD_USAGE.messageEnvelope })
|
|
235
|
-
.label('SMTPEnvelope')
|
|
236
|
-
.when('mailMerge', {
|
|
237
|
-
is: Joi.exist().not(false, null),
|
|
238
|
-
then: Joi.forbidden('y')
|
|
239
|
-
}),
|
|
240
|
-
|
|
241
|
-
raw: Joi.string()
|
|
242
|
-
.base64()
|
|
243
|
-
.max(MAX_ATTACHMENT_SIZE)
|
|
244
|
-
.example('TUlNRS1WZXJzaW9uOiAxLjANClN1YmplY3Q6IGhlbGxvIHdvcmxkDQoNCkhlbGxvIQ0K')
|
|
245
|
-
.description('A Base64-encoded email message in RFC 822 format')
|
|
246
|
-
.meta({ usage: FIELD_USAGE.messageRaw })
|
|
247
|
-
.label('RFC822Raw')
|
|
248
|
-
.when('mailMerge', {
|
|
249
|
-
is: Joi.exist().not(false, null),
|
|
250
|
-
then: Joi.forbidden('y')
|
|
251
|
-
}),
|
|
252
|
-
|
|
253
|
-
from: fromAddressSchema,
|
|
254
|
-
|
|
255
|
-
replyTo: Joi.array()
|
|
256
|
-
.items(addressSchema.label('ReplyToAddress'))
|
|
257
|
-
.single()
|
|
258
|
-
.example([{ name: 'From Me', address: 'sender@example.com' }])
|
|
259
|
-
.description('List of Reply-To addresses')
|
|
260
|
-
.label('ReplyTo'),
|
|
261
|
-
|
|
262
|
-
to: Joi.array()
|
|
263
|
-
.items(addressSchema.label('ToAddress'))
|
|
264
|
-
.single()
|
|
265
|
-
.example([{ address: 'recipient@example.com' }])
|
|
266
|
-
.description('List of recipient addresses')
|
|
267
|
-
.label('ToAddressList')
|
|
268
|
-
.when('mailMerge', {
|
|
269
|
-
is: Joi.exist().not(false, null),
|
|
270
|
-
then: Joi.forbidden('y')
|
|
271
|
-
}),
|
|
272
|
-
|
|
273
|
-
cc: Joi.array()
|
|
274
|
-
.items(addressSchema.label('CcAddress'))
|
|
275
|
-
.single()
|
|
276
|
-
.description('List of CC addresses')
|
|
277
|
-
.label('CcAddressList')
|
|
278
|
-
.when('mailMerge', {
|
|
279
|
-
is: Joi.exist().not(false, null),
|
|
280
|
-
then: Joi.forbidden('y')
|
|
281
|
-
}),
|
|
282
|
-
|
|
283
|
-
bcc: Joi.array()
|
|
284
|
-
.items(addressSchema.label('BccAddress'))
|
|
285
|
-
.single()
|
|
286
|
-
.description('List of BCC addresses')
|
|
287
|
-
.label('BccAddressList')
|
|
288
|
-
.when('mailMerge', {
|
|
289
|
-
is: Joi.exist().not(false, null),
|
|
290
|
-
then: Joi.forbidden('y')
|
|
291
|
-
}),
|
|
292
|
-
|
|
293
|
-
subject: templateSchemas.subject,
|
|
294
|
-
text: templateSchemas.text,
|
|
295
|
-
html: templateSchemas.html,
|
|
296
|
-
previewText: templateSchemas.previewText,
|
|
297
|
-
|
|
298
|
-
template: Joi.string().max(256).example('example').description('Stored template ID to load the email content from'),
|
|
299
|
-
|
|
300
|
-
render: Joi.object({
|
|
301
|
-
format: Joi.string()
|
|
302
|
-
.valid('html', 'markdown')
|
|
303
|
-
.default('html')
|
|
304
|
-
.description('Markup language the template is written in')
|
|
305
|
-
.meta({ enumDescriptions: ENUM_DESCRIPTIONS.renderFormat })
|
|
306
|
-
.label('RenderFormat'),
|
|
307
|
-
params: Joi.object()
|
|
308
|
-
.label('RenderValues')
|
|
309
|
-
.example({ firstName: 'Nyan', orderId: '4815' })
|
|
310
|
-
.description('An object of variables for the template renderer')
|
|
311
|
-
})
|
|
312
|
-
.allow(false)
|
|
313
|
-
.description('Template rendering options. Set to `false` to send the template as-is, without rendering it.')
|
|
314
|
-
.when('mailMerge', {
|
|
315
|
-
is: Joi.exist().not(false, null),
|
|
316
|
-
then: Joi.forbidden('y')
|
|
317
|
-
})
|
|
318
|
-
.label('TemplateRender'),
|
|
319
|
-
|
|
320
|
-
mailMerge: Joi.array()
|
|
321
|
-
.items(
|
|
322
|
-
Joi.object({
|
|
323
|
-
to: addressSchema.label('ToAddress').required(),
|
|
324
|
-
messageId: Joi.string().max(996).example('<test123@example.com>').description('Message ID'),
|
|
325
|
-
params: Joi.object()
|
|
326
|
-
.label('RenderValues')
|
|
327
|
-
.example({ firstName: 'Nyan', orderId: '4815' })
|
|
328
|
-
.description('An object of variables for the template renderer'),
|
|
329
|
-
sendAt: Joi.date()
|
|
330
|
-
.iso()
|
|
331
|
-
.example('2021-07-08T07:06:34.336Z')
|
|
332
|
-
.description('Send message at specified time. Overrides message level `sendAt` value.')
|
|
333
|
-
}).label('MailMergeListEntry')
|
|
334
|
-
)
|
|
335
|
-
.min(1)
|
|
336
|
-
.max(MAX_MAIL_MERGE_ENTRIES)
|
|
337
|
-
.description(`Mail merge options. A separate email is generated for each recipient, up to ${MAX_MAIL_MERGE_ENTRIES} per request`)
|
|
338
|
-
.meta({ usage: FIELD_USAGE.mailMerge })
|
|
339
|
-
.label('MailMergeList'),
|
|
340
|
-
|
|
341
|
-
attachments: Joi.array()
|
|
342
|
-
.items(
|
|
343
|
-
Joi.object({
|
|
344
|
-
filename: Joi.string().max(256).example('transparent.gif'),
|
|
345
|
-
content: Joi.string()
|
|
346
|
-
.base64()
|
|
347
|
-
.max(MAX_ATTACHMENT_SIZE)
|
|
348
|
-
.required()
|
|
349
|
-
.example('R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=')
|
|
350
|
-
.description('Base64 formatted attachment file')
|
|
351
|
-
.when('reference', {
|
|
352
|
-
is: Joi.exist().not(false, null),
|
|
353
|
-
then: Joi.forbidden(),
|
|
354
|
-
otherwise: Joi.required()
|
|
355
|
-
}),
|
|
356
|
-
|
|
357
|
-
contentType: Joi.string().lowercase().max(256).example('image/gif'),
|
|
358
|
-
contentDisposition: Joi.string().lowercase().valid('inline', 'attachment').label('AttachmentContentDisposition'),
|
|
359
|
-
cid: Joi.string().max(256).example('unique-image-id@localhost').description('Content-ID value for embedded images'),
|
|
360
|
-
encoding: Joi.string().valid('base64').default('base64').label('AttachmentEncoding'),
|
|
361
|
-
|
|
362
|
-
reference: Joi.string()
|
|
363
|
-
.base64({ paddingRequired: false, urlSafe: true })
|
|
364
|
-
.max(256)
|
|
365
|
-
.allow(false, null)
|
|
366
|
-
.example('AAAAAQAACnAcde')
|
|
367
|
-
.description('References an existing attachment by its ID instead of providing new attachment content')
|
|
368
|
-
.meta({ usage: FIELD_USAGE.attachmentReference })
|
|
369
|
-
.label('AttachmentReference')
|
|
370
|
-
}).label('UploadAttachment')
|
|
371
|
-
)
|
|
372
|
-
.max(MAX_MESSAGE_ATTACHMENTS)
|
|
373
|
-
.description('List of attachments')
|
|
374
|
-
.label('UploadAttachmentList'),
|
|
375
|
-
|
|
376
|
-
messageId: Joi.string().max(996).example('<test123@example.com>').description('Message ID'),
|
|
377
|
-
headers: Joi.object().label('CustomHeaders').description('Custom Headers').unknown().example({
|
|
378
|
-
'X-My-Custom-Header': 'Custom header value'
|
|
379
|
-
}),
|
|
380
|
-
|
|
381
|
-
trackingEnabled: Joi.boolean()
|
|
382
|
-
.example(false)
|
|
383
|
-
.description('Should EmailEngine track clicks and opens for this message')
|
|
384
|
-
.meta({ swaggerHidden: true }),
|
|
385
|
-
|
|
386
|
-
trackOpens: Joi.boolean().example(false).description('Should EmailEngine track opens for this message'),
|
|
387
|
-
trackClicks: Joi.boolean().example(false).description('Should EmailEngine track clicks for this message'),
|
|
388
|
-
|
|
389
|
-
copy: Joi.boolean()
|
|
390
|
-
.allow(null)
|
|
391
|
-
.example(null)
|
|
392
|
-
.description("If set then either copies the message to the Sent Mail folder or not. If not set then uses the account's default setting")
|
|
393
|
-
.meta({ usage: FIELD_USAGE.messageCopy }),
|
|
394
|
-
|
|
395
|
-
sentMailPath: Joi.string()
|
|
396
|
-
.empty('')
|
|
397
|
-
.max(1024)
|
|
398
|
-
.example('Sent Mail')
|
|
399
|
-
.description("Upload sent message to this folder. By default the account's Sent Mail folder is used."),
|
|
400
|
-
|
|
401
|
-
locale: Joi.string().empty('').max(100).example('fr').description('Optional locale').label('MessageLocale'),
|
|
402
|
-
tz: Joi.string().empty('').max(100).example('Europe/Tallinn').description('Optional timezone'),
|
|
403
|
-
|
|
404
|
-
sendAt: sendAtSchema,
|
|
405
|
-
deliveryAttempts: deliveryAttemptsSchema,
|
|
406
|
-
gateway: gatewaySchema,
|
|
407
|
-
|
|
408
|
-
listId: Joi.string()
|
|
409
|
-
.hostname()
|
|
410
|
-
.example('test-list')
|
|
411
|
-
.description(
|
|
412
|
-
'List ID for Mail Merge. Must use a subdomain name format. Lists are registered ad-hoc, so a new identifier defines a new list.'
|
|
413
|
-
)
|
|
414
|
-
.label('ListID')
|
|
415
|
-
.when('mailMerge', {
|
|
416
|
-
is: Joi.exist().not(false, null),
|
|
417
|
-
then: Joi.optional(),
|
|
418
|
-
otherwise: Joi.forbidden()
|
|
419
|
-
}),
|
|
420
|
-
|
|
421
|
-
dsn: dsnSchema.label('DSN'),
|
|
422
|
-
|
|
423
|
-
baseUrl: Joi.string()
|
|
424
|
-
.trim()
|
|
425
|
-
.empty('')
|
|
426
|
-
.uri({
|
|
427
|
-
scheme: ['http', 'https'],
|
|
428
|
-
allowRelative: false
|
|
429
|
-
})
|
|
430
|
-
.example('https://customer123.myservice.com')
|
|
431
|
-
.description('Optional base URL for trackers. This URL must point to your EmailEngine instance.'),
|
|
432
|
-
|
|
433
|
-
proxy: proxySchema,
|
|
434
|
-
localAddress: localAddressSchema,
|
|
435
|
-
|
|
436
|
-
dryRun: apiBoolean()
|
|
437
|
-
.default(false)
|
|
438
|
-
.description(
|
|
439
|
-
'If true, then EmailEngine does not send the email and returns an RFC822 formatted email file. Tracking information is not added to the email.'
|
|
440
|
-
)
|
|
441
|
-
.label('Preview')
|
|
442
|
-
})
|
|
443
|
-
.oxor('raw', 'html')
|
|
444
|
-
.oxor('raw', 'text')
|
|
445
|
-
.oxor('raw', 'text')
|
|
446
|
-
.oxor('raw', 'attachments')
|
|
447
|
-
.label('SubmitMessage')
|
|
448
|
-
.example({
|
|
449
|
-
to: [
|
|
450
|
-
{
|
|
451
|
-
name: 'Nyan Cat',
|
|
452
|
-
address: 'nyan.cat@example.com'
|
|
453
|
-
}
|
|
454
|
-
],
|
|
455
|
-
subject: 'What a wonderful message!',
|
|
456
|
-
text: 'Hello from myself!',
|
|
457
|
-
html: '<p>Hello from myself!</p>',
|
|
458
|
-
attachments: [
|
|
459
|
-
{
|
|
460
|
-
filename: 'transparent.gif',
|
|
461
|
-
content: 'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=',
|
|
462
|
-
contentType: 'image/gif'
|
|
463
|
-
}
|
|
464
|
-
]
|
|
465
|
-
})
|
|
531
|
+
payload: buildSubmitMessagePayloadSchema(MAX_ATTACHMENT_SIZE)
|
|
466
532
|
},
|
|
467
533
|
|
|
468
534
|
response: {
|
|
469
|
-
schema:
|
|
470
|
-
response: Joi.string().example('Queued for delivery'),
|
|
471
|
-
messageId: Joi.string()
|
|
472
|
-
.example('<a2184d08-a470-fec6-a493-fa211a3756e9@example.com>')
|
|
473
|
-
.description('Message-ID header value. Not present for bulk messages.'),
|
|
474
|
-
queueId: Joi.string().example('d41f0423195f271f').description('Queue identifier for scheduled email. Not present for bulk messages.'),
|
|
475
|
-
sendAt: Joi.date().example('2021-07-08T07:06:34.336Z').description('Scheduled send time'),
|
|
476
|
-
|
|
477
|
-
reference: Joi.object({
|
|
478
|
-
message: Joi.string()
|
|
479
|
-
.base64({ paddingRequired: false, urlSafe: true })
|
|
480
|
-
.max(256)
|
|
481
|
-
.example('AAAAAQAACnA')
|
|
482
|
-
.description('Referenced message ID. Not present when only a thread ID was referenced'),
|
|
483
|
-
threadId: threadIdSchema.description('Referenced thread ID (Gmail API accounts only)').label('SubmitResponseReferenceThreadId'),
|
|
484
|
-
success: Joi.boolean().example(true).description('Was the referenced message processed successfully').label('ResponseReferenceSuccess'),
|
|
485
|
-
error: Joi.string().example('Referenced message was not found').description('An error message if referenced message processing failed')
|
|
486
|
-
})
|
|
487
|
-
.description('Reference info if referencing was requested')
|
|
488
|
-
.label('ResponseReference'),
|
|
489
|
-
|
|
490
|
-
preview: Joi.string()
|
|
491
|
-
.base64()
|
|
492
|
-
.example('Q29udGVudC1UeXBlOiBtdWx0aX...')
|
|
493
|
-
.description('Base64 encoded RFC822 email if a preview was requested. Not returned for mail-merge submissions.')
|
|
494
|
-
.label('ResponsePreview'),
|
|
495
|
-
|
|
496
|
-
idempotency: idempotencyResponseSchema,
|
|
497
|
-
|
|
498
|
-
mailMerge: Joi.array()
|
|
499
|
-
.items(
|
|
500
|
-
Joi.object({
|
|
501
|
-
success: Joi.boolean().example(true).description('Was the message queued successfully').label('ResponseReferenceSuccess'),
|
|
502
|
-
to: addressSchema.label('ToAddressSingle'),
|
|
503
|
-
messageId: Joi.string().max(996).example('<test123@example.com>').description('Message ID'),
|
|
504
|
-
queueId: Joi.string().example('d41f0423195f271f').description('Queue identifier for the scheduled email'),
|
|
505
|
-
sendAt: Joi.date().iso().example('2021-07-08T07:06:34.336Z').description('Scheduled send time for this recipient'),
|
|
506
|
-
error: Joi.string().example('Failed to queue message').description('Error message if queueing failed for this recipient'),
|
|
507
|
-
code: Joi.string().example('EENVELOPE').description('Error code if queueing failed for this recipient'),
|
|
508
|
-
statusCode: Joi.number()
|
|
509
|
-
.integer()
|
|
510
|
-
.allow(null)
|
|
511
|
-
.example(500)
|
|
512
|
-
.description('Error status code if queueing failed for this recipient'),
|
|
513
|
-
skipped: Joi.object({
|
|
514
|
-
reason: Joi.string().example('unsubscribe').description('Why this message was skipped'),
|
|
515
|
-
listId: Joi.string().example('test-list')
|
|
516
|
-
})
|
|
517
|
-
.description('Info about skipped message. If this value is set, then the message was not sent')
|
|
518
|
-
.label('SkippedMessageInfo')
|
|
519
|
-
})
|
|
520
|
-
.label('BulkResponseEntry')
|
|
521
|
-
.example({
|
|
522
|
-
success: true,
|
|
523
|
-
to: {
|
|
524
|
-
name: 'Andris 2',
|
|
525
|
-
address: 'andris@ethereal.email'
|
|
526
|
-
},
|
|
527
|
-
messageId: '<19b9c433-d428-f6d8-1d00-d666ebcadfc4@ekiri.ee>',
|
|
528
|
-
queueId: '1812477338914c8372a',
|
|
529
|
-
sendAt: '2021-07-08T07:06:34.336Z'
|
|
530
|
-
})
|
|
531
|
-
.unknown()
|
|
532
|
-
)
|
|
533
|
-
.label('BulkResponseList')
|
|
534
|
-
.description('Bulk message responses')
|
|
535
|
-
}).label('SubmitMessageResponse'),
|
|
535
|
+
schema: buildSubmitMessageResponseSchema(),
|
|
536
536
|
failAction: 'log'
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
539
|
});
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function registerSubmitDraft(server, args) {
|
|
543
|
+
const { call, CORS_CONFIG } = args;
|
|
540
544
|
|
|
541
545
|
server.route({
|
|
542
546
|
method: 'POST',
|
|
@@ -573,6 +577,23 @@ async function init(args) {
|
|
|
573
577
|
tags: ['api', 'Submit'],
|
|
574
578
|
|
|
575
579
|
plugins: {
|
|
580
|
+
mcp: {
|
|
581
|
+
name: 'send_draft',
|
|
582
|
+
title: 'Send draft',
|
|
583
|
+
description:
|
|
584
|
+
'Send a draft that is already stored in the account, by its message id - confirm with the user before calling this. ' +
|
|
585
|
+
'This is the second half of a review workflow: create_draft stores the message in the Drafts folder and returns its id, the user looks it over (get_message reads it back), ' +
|
|
586
|
+
'and send_draft then sends that same draft as it is. The draft carries its own recipients, subject and content, so nothing else is needed. ' +
|
|
587
|
+
'The message has to be a draft: in the Drafts folder or flagged \\Draft. Once sent it is removed from Drafts and, unless the account is set not to keep copies, filed in Sent. ' +
|
|
588
|
+
'Delivery is queued; the response carries the queue id for get_outbox.',
|
|
589
|
+
// The draft and nothing else. Every field of the payload is an override of a
|
|
590
|
+
// decision the operator made when connecting the account (the SMTP envelope,
|
|
591
|
+
// the gateway, DSN, whether and where the sent copy is filed, how often
|
|
592
|
+
// delivery is retried) or a network override (`proxy`, `localAddress`). An
|
|
593
|
+
// allowlist for the reason send_message keeps one: a field added to the route
|
|
594
|
+
// later must not join the agent-facing schema by default.
|
|
595
|
+
keep: ['account', 'message']
|
|
596
|
+
},
|
|
576
597
|
openapi: {
|
|
577
598
|
'x-ee-impact': IMPACT.SENDS,
|
|
578
599
|
'x-ee-behavior': [BEHAVIOR.QUEUED_DELIVERY, BEHAVIOR.SENT_FOLDER_UPLOAD],
|
|
@@ -681,4 +702,11 @@ async function init(args) {
|
|
|
681
702
|
});
|
|
682
703
|
}
|
|
683
704
|
|
|
705
|
+
async function init(args) {
|
|
706
|
+
const { server } = args;
|
|
707
|
+
|
|
708
|
+
registerSubmitMessage(server, args);
|
|
709
|
+
registerSubmitDraft(server, args);
|
|
710
|
+
}
|
|
711
|
+
|
|
684
712
|
module.exports = init;
|