Skip to content

Commit 36d5620

Browse files
committed
Enhance mail transport configuration with detailed parameters and debugging options
1 parent 490d99a commit 36d5620

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/app.module.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,27 @@ import { MigrationsModule } from './migrations/migrations.module';
3434
inject: [MailadmService],
3535
useFactory: async (service: MailadmService) => {
3636
const params = await service.getParams();
37+
const regex = /^(smtps?|):\/\/([a-zA-Z0-9.-]+|\d{1,3}(?:\.\d{1,3}){3}|\[(?:[0-9a-fA-F:]+)\]):(\d+)$/;
38+
const [_, protocol, host, port] = `${params.host}`.match(regex);
39+
const isDev = process.env.NODE_ENV === 'development';
40+
3741
return {
38-
transport: params.host,
42+
transport: {
43+
host,
44+
port: parseInt(port),
45+
from: params.sender,
46+
secure: protocol === 'smtps' && port === '465',
47+
requireTLS: protocol === 'smtps' && port === '587',
48+
auth: {
49+
user: params.username,
50+
pass: params.password,
51+
},
52+
tls: {
53+
ciphers: 'SSLv3,TLSv1,TLSv1.1,TLSv1.2',
54+
},
55+
debug: isDev,
56+
logger: isDev,
57+
},
3958
defaults: {
4059
from: params.sender,
4160
},

0 commit comments

Comments
 (0)