Skip to content

Commit

Permalink
SMTP authentication is optional (#2765)
Browse files Browse the repository at this point in the history
Co-authored-by: Laurent Magnien <[email protected]>
  • Loading branch information
lmagnien and Laurent Magnien authored Mar 9, 2024
1 parent ce58f06 commit bdc13f9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions api/extensions/ext_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def init_app(self, app: Flask):
from libs.smtp import SMTPClient
if not app.config.get('SMTP_SERVER') or not app.config.get('SMTP_PORT'):
raise ValueError('SMTP_SERVER and SMTP_PORT are required for smtp mail type')
if not app.config.get('SMTP_USERNAME') or not app.config.get('SMTP_PASSWORD'):
raise ValueError('SMTP_USERNAME and SMTP_PASSWORD are required for smtp mail type')
self._client = SMTPClient(
server=app.config.get('SMTP_SERVER'),
port=app.config.get('SMTP_PORT'),
Expand Down
3 changes: 2 additions & 1 deletion api/libs/smtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def send(self, mail: dict):
smtp = smtplib.SMTP(self.server, self.port)
if self._use_tls:
smtp.starttls()
smtp.login(self.username, self.password)
if (self.username):
smtp.login(self.username, self.password)
msg = MIMEMultipart()
msg['Subject'] = mail['subject']
msg['From'] = self._from
Expand Down

0 comments on commit bdc13f9

Please sign in to comment.