mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-13 08:12:32 +10:00
add STMP_SECURE and changed auth config (#81)
* add STMP_SECURE and changed auth config * relocated logic to mail.provider.ts
This commit is contained in:
@ -87,6 +87,13 @@ export class EnvironmentService {
|
|||||||
return parseInt(this.configService.get<string>('SMTP_PORT'));
|
return parseInt(this.configService.get<string>('SMTP_PORT'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSmtpSecure(): boolean {
|
||||||
|
const secure = this.configService
|
||||||
|
.get<string>('SMTP_SECURE', 'false')
|
||||||
|
.toLowerCase();
|
||||||
|
return secure === 'true';
|
||||||
|
}
|
||||||
|
|
||||||
getSmtpUsername(): string {
|
getSmtpUsername(): string {
|
||||||
return this.configService.get<string>('SMTP_USERNAME');
|
return this.configService.get<string>('SMTP_USERNAME');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,16 +26,21 @@ export const mailDriverConfigProvider = {
|
|||||||
|
|
||||||
switch (driver) {
|
switch (driver) {
|
||||||
case MailOption.SMTP:
|
case MailOption.SMTP:
|
||||||
|
let auth = undefined;
|
||||||
|
if (environmentService.getSmtpUsername() && environmentService.getSmtpPassword()) {
|
||||||
|
auth = {
|
||||||
|
user: environmentService.getSmtpUsername(),
|
||||||
|
pass: environmentService.getSmtpPassword(),
|
||||||
|
};
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
driver,
|
driver,
|
||||||
config: {
|
config: {
|
||||||
host: environmentService.getSmtpHost(),
|
host: environmentService.getSmtpHost(),
|
||||||
port: environmentService.getSmtpPort(),
|
port: environmentService.getSmtpPort(),
|
||||||
connectionTimeout: 30 * 1000, // 30 seconds
|
connectionTimeout: 30 * 1000, // 30 seconds
|
||||||
auth: {
|
auth,
|
||||||
user: environmentService.getSmtpUsername(),
|
secure: environmentService.getSmtpSecure(),
|
||||||
pass: environmentService.getSmtpPassword(),
|
|
||||||
},
|
|
||||||
} as SMTPTransport.Options,
|
} as SMTPTransport.Options,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user