@ultimat3/mail 31.31.0 → 31.32.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/package.json +7 -7
- package/src/driver-resend.ts +2 -1
- package/src/driver-smtp.ts +8 -3
- package/src/driver.ts +1 -0
- package/src/layout.ts +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultimat3/mail",
|
|
3
|
-
"version": "31.
|
|
3
|
+
"version": "31.32.0",
|
|
4
4
|
"description": "Transactional email as data: one template renders HTML and text, sent through a job.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ultimate",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"test": "bun test"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@ultimat3/core": "31.
|
|
48
|
-
"@ultimat3/i18n": "31.
|
|
49
|
-
"@ultimat3/jobs": "31.
|
|
50
|
-
"@ultimat3/schema": "31.
|
|
51
|
-
"@ultimat3/storage": "31.
|
|
52
|
-
"@ultimat3/time": "31.
|
|
47
|
+
"@ultimat3/core": "31.32.0",
|
|
48
|
+
"@ultimat3/i18n": "31.32.0",
|
|
49
|
+
"@ultimat3/jobs": "31.32.0",
|
|
50
|
+
"@ultimat3/schema": "31.32.0",
|
|
51
|
+
"@ultimat3/storage": "31.32.0",
|
|
52
|
+
"@ultimat3/time": "31.32.0"
|
|
53
53
|
}
|
|
54
54
|
}
|
package/src/driver-resend.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
isRetryableStatus,
|
|
14
14
|
logger,
|
|
15
15
|
nanoid,
|
|
16
|
+
renderFixShellArg,
|
|
16
17
|
renderThrowable,
|
|
17
18
|
} from '@ultimat3/core';
|
|
18
19
|
import { outboundResponse } from '@ultimat3/core/outbound';
|
|
@@ -192,7 +193,7 @@ export function resendMailDriver(options: ResendDriverOptions): MailDriver {
|
|
|
192
193
|
stage: 'request',
|
|
193
194
|
detail: `${reason} — nothing left this host for ${baseUrl}/emails (egress, DNS or TLS)`,
|
|
194
195
|
retryable: true,
|
|
195
|
-
fix: `curl -sS -m 5 -o /dev/null ${baseUrl}/emails`,
|
|
196
|
+
fix: `curl -sS -m 5 -o /dev/null ${renderFixShellArg(`${baseUrl}/emails`, '<RESEND_BASE_URL>/emails')}`,
|
|
196
197
|
});
|
|
197
198
|
}
|
|
198
199
|
|
package/src/driver-smtp.ts
CHANGED
|
@@ -184,7 +184,8 @@ export function smtpMailDriver(options: SmtpDriverOptions): MailDriver {
|
|
|
184
184
|
const dial: SmtpTarget = { host: target.host, port: target.port, tls: target.tls, timeoutMs };
|
|
185
185
|
// `smtps://` is encrypted from the first byte; a submission port has to be told to upgrade, or
|
|
186
186
|
// the probe named in the fix lines below opens a socket and then waits forever for a handshake.
|
|
187
|
-
|
|
187
|
+
// Screened once: both probe fixes below splice it, and a fix is pasted into a shell.
|
|
188
|
+
const endpoint = renderFixShellArg(`${target.host}:${String(target.port)}`, '<SMTP host>:<port>');
|
|
188
189
|
|
|
189
190
|
return {
|
|
190
191
|
name: 'smtp',
|
|
@@ -215,7 +216,9 @@ export function smtpMailDriver(options: SmtpDriverOptions): MailDriver {
|
|
|
215
216
|
stage: 'connect',
|
|
216
217
|
detail: `${target.host}:${target.port}, from SMTP_URL in .env — ${messageOf(error)}`,
|
|
217
218
|
retryable: true,
|
|
218
|
-
fix:
|
|
219
|
+
fix: target.tls
|
|
220
|
+
? `openssl s_client -connect ${endpoint}`
|
|
221
|
+
: `openssl s_client -starttls smtp -connect ${endpoint}`,
|
|
219
222
|
});
|
|
220
223
|
});
|
|
221
224
|
|
|
@@ -236,7 +239,9 @@ export function smtpMailDriver(options: SmtpDriverOptions): MailDriver {
|
|
|
236
239
|
stage: 'data',
|
|
237
240
|
detail: `${messageOf(error)} — the mail log on ${target.host} records why it dropped this`,
|
|
238
241
|
retryable: true,
|
|
239
|
-
fix:
|
|
242
|
+
fix: target.tls
|
|
243
|
+
? `openssl s_client -crlf -connect ${endpoint}`
|
|
244
|
+
: `openssl s_client -crlf -starttls smtp -connect ${endpoint}`,
|
|
240
245
|
});
|
|
241
246
|
} finally {
|
|
242
247
|
stream.close();
|
package/src/driver.ts
CHANGED
|
@@ -224,6 +224,7 @@ export function logMailDriver(logger = rootLogger): MailDriver {
|
|
|
224
224
|
name: 'log',
|
|
225
225
|
send(message: MailMessage): Promise<SendResult> {
|
|
226
226
|
const result = resultFor('log', message, `log_${nanoid(12)}`);
|
|
227
|
+
// info: the log driver delivers BY logging: this line is the message the developer reads instead of an inbox.
|
|
227
228
|
logger.info('mail.send', {
|
|
228
229
|
mailId: message.mailId,
|
|
229
230
|
to: message.to.length,
|
package/src/layout.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// renderer, because email clients drop <style> and templates must never carry a raw hex.
|
|
4
4
|
// Table-based and 600px wide: Outlook still renders with Word's HTML engine.
|
|
5
5
|
|
|
6
|
-
import { escapeHtml } from '@ultimat3/core';
|
|
6
|
+
import { assert, escapeHtml, renderCauseValue } from '@ultimat3/core';
|
|
7
7
|
import { mailLayoutDuplicate } from './errors';
|
|
8
8
|
import { safeMailHref, styleAttr } from './html';
|
|
9
9
|
|
|
@@ -40,6 +40,12 @@ export const MAIL_TOKENS = Object.freeze<Record<MailToken, Readonly<Record<Color
|
|
|
40
40
|
|
|
41
41
|
/** Resolve a token to a hex value. The only function in the package that returns a colour. */
|
|
42
42
|
export function token(name: MailToken, scheme: ColorScheme = 'light'): string {
|
|
43
|
+
// Own keys only: a name reaching here untyped must never answer an `Object.prototype` member.
|
|
44
|
+
assert(
|
|
45
|
+
Object.hasOwn(MAIL_TOKENS, name),
|
|
46
|
+
`${renderCauseValue(name)} is not a mail token`,
|
|
47
|
+
"token('accentBg') # a key of MAIL_TOKENS",
|
|
48
|
+
);
|
|
43
49
|
return MAIL_TOKENS[name][scheme];
|
|
44
50
|
}
|
|
45
51
|
|