mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Server: Do not set the SMTP auth option when user or password are not set (#5791)
This commit is contained in:
parent
605f12552e
commit
920847245f
@ -1,6 +1,7 @@
|
||||
import Logger from '@joplin/lib/Logger';
|
||||
import BaseService from './BaseService';
|
||||
import Mail = require('nodemailer/lib/mailer');
|
||||
import SMTPTransport = require('nodemailer/lib/smtp-transport');
|
||||
import { createTransport } from 'nodemailer';
|
||||
import { Email, EmailSender } from '../services/database/types';
|
||||
import { errorToString } from '../utils/errors';
|
||||
@ -24,16 +25,18 @@ export default class EmailService extends BaseService {
|
||||
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({
|
||||
const options: SMTPTransport.Options = {
|
||||
host: this.config.mailer.host,
|
||||
port: this.config.mailer.port,
|
||||
secure: this.config.mailer.secure,
|
||||
auth: {
|
||||
};
|
||||
if (this.config.mailer.authUser || this.config.mailer.authPassword) {
|
||||
options.auth = {
|
||||
user: this.config.mailer.authUser,
|
||||
pass: this.config.mailer.authPassword,
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
this.transport_ = createTransport(options);
|
||||
|
||||
await this.transport_.verify();
|
||||
logger.info('Transporter is operational - service will be enabled');
|
||||
|
Loading…
Reference in New Issue
Block a user