소스 검색

SMTP authentication is optional (#2765)

Co-authored-by: Laurent Magnien <laurent.magnien@adsn.fr>
tags/0.5.9
Laurent Magnien 1 년 전
부모
커밋
bdc13f9238
No account linked to committer's email address
2개의 변경된 파일2개의 추가작업 그리고 3개의 파일을 삭제
  1. 0
    2
      api/extensions/ext_mail.py
  2. 2
    1
      api/libs/smtp.py

+ 0
- 2
api/extensions/ext_mail.py 파일 보기

@@ -32,8 +32,6 @@ class Mail:
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'),

+ 2
- 1
api/libs/smtp.py 파일 보기

@@ -16,7 +16,8 @@ class SMTPClient:
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

Loading…
취소
저장