feat: add config for mail server name (#13632)

fix #13627

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added configurable display names for primary and fallback SMTP
servers, improving email sender identification.
* Defaults to “AFFiNE Server,” with support for MAILER_SERVERNAME
environment variable for the primary SMTP.
* Exposed in admin settings for easy setup alongside existing SMTP
options.
* Names are now passed through to mail transport options for consistent
use across emails.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
DarkSky
2025-09-22 19:52:15 +08:00
committed by GitHub
parent 7fe95f50f4
commit e3f3c8c4a8
4 changed files with 31 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ declare global {
interface AppConfigSchema {
mailer: {
SMTP: {
name: string;
host: string;
port: number;
username: string;
@@ -16,6 +17,7 @@ declare global {
fallbackDomains: ConfigItem<string[]>;
fallbackSMTP: {
name: string;
host: string;
port: number;
username: string;
@@ -28,6 +30,11 @@ declare global {
}
defineModuleConfig('mailer', {
'SMTP.name': {
desc: 'Name of the email server (e.g. your domain name)',
default: 'AFFiNE Server',
env: 'MAILER_SERVERNAME',
},
'SMTP.host': {
desc: 'Host of the email server (e.g. smtp.gmail.com)',
default: '',
@@ -64,6 +71,10 @@ defineModuleConfig('mailer', {
default: [],
shape: z.array(z.string()),
},
'fallbackSMTP.name': {
desc: 'Name of the fallback email server (e.g. your domain name)',
default: 'AFFiNE Server',
},
'fallbackSMTP.host': {
desc: 'Host of the email server (e.g. smtp.gmail.com)',
default: '',

View File

@@ -20,6 +20,7 @@ function configToSMTPOptions(
config: AppConfig['mailer']['SMTP']
): SMTPTransport.Options {
return {
name: config.name,
host: config.host,
port: config.port,
tls: {