瀏覽代碼

SMTP authentication is optional (#2765)

Co-authored-by: Laurent Magnien <laurent.magnien@adsn.fr>
tags/0.5.9
Laurent Magnien 1 年之前
父節點
當前提交
bdc13f9238
沒有連結到貢獻者的電子郵件帳戶。
共有 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 查看文件

from libs.smtp import SMTPClient from libs.smtp import SMTPClient
if not app.config.get('SMTP_SERVER') or not app.config.get('SMTP_PORT'): 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') 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( self._client = SMTPClient(
server=app.config.get('SMTP_SERVER'), server=app.config.get('SMTP_SERVER'),
port=app.config.get('SMTP_PORT'), port=app.config.get('SMTP_PORT'),

+ 2
- 1
api/libs/smtp.py 查看文件

smtp = smtplib.SMTP(self.server, self.port) smtp = smtplib.SMTP(self.server, self.port)
if self._use_tls: if self._use_tls:
smtp.starttls() smtp.starttls()
smtp.login(self.username, self.password)
if (self.username):
smtp.login(self.username, self.password)
msg = MIMEMultipart() msg = MIMEMultipart()
msg['Subject'] = mail['subject'] msg['Subject'] = mail['subject']
msg['From'] = self._from msg['From'] = self._from

Loading…
取消
儲存