mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 04:55:42 +09:00
fix(email): test saved SMTP config and add TLS modes (#3388)
This commit is contained in:
1 parent
45b78a13c2
commit
cca8227ca6
66 files changed
+2464
-319
No files matched your search
@@ -0,0 +1,24 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type {ValueOf} from '@fluxer/constants/src/ValueOf';
|
||||
|
||||
export const SmtpTlsModes = {
|
||||
IMPLICIT: 'implicit',
|
||||
STARTTLS: 'starttls',
|
||||
OPPORTUNISTIC: 'opportunistic',
|
||||
NONE: 'none',
|
||||
} as const;
|
||||
|
||||
export type SmtpTlsMode = ValueOf<typeof SmtpTlsModes>;
|
||||
|
||||
const SMTP_IMPLICIT_TLS_PORT = 465;
|
||||
|
||||
export function resolveSmtpTlsMode(mode: SmtpTlsMode | null | undefined, port: number): SmtpTlsMode {
|
||||
if (mode) return mode;
|
||||
return port === SMTP_IMPLICIT_TLS_PORT ? SmtpTlsModes.IMPLICIT : SmtpTlsModes.STARTTLS;
|
||||
}
|
||||
|
||||
export function smtpTlsModeFromSecure(secure: boolean | null | undefined): SmtpTlsMode | null {
|
||||
if (secure == null) return null;
|
||||
return secure ? SmtpTlsModes.IMPLICIT : SmtpTlsModes.OPPORTUNISTIC;
|
||||
}
|
||||
Reference in new issue
Block a user