Skip to content

Commit

Permalink
Server: Disable mailer service if no-reply email is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Nov 3, 2021
1 parent 8c6d78e commit ce5c5d6
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/server/src/services/EmailService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@ export default class EmailService extends BaseService {

private async transport(): Promise<Mail> {
if (!this.transport_) {
this.transport_ = createTransport({
host: this.config.mailer.host,
port: this.config.mailer.port,
secure: this.config.mailer.secure,
auth: {
user: this.config.mailer.authUser,
pass: this.config.mailer.authPassword,
},
});

try {
if (!this.senderInfo(EmailSender.NoReply).email) {
throw new Error('No-reply email must be set for email service to work (Set env variable MAILER_NOREPLY_EMAIL)');
}

this.transport_ = createTransport({
host: this.config.mailer.host,
port: this.config.mailer.port,
secure: this.config.mailer.secure,
auth: {
user: this.config.mailer.authUser,
pass: this.config.mailer.authPassword,
},
});

await this.transport_.verify();
logger.info('Transporter is operational - service will be enabled');
} catch (error) {
Expand Down

0 comments on commit ce5c5d6

Please sign in to comment.