Not all SMTP servers require authentication #1277

Closed
opened 2026-02-21 17:31:45 -05:00 by yindo · 0 comments
Owner

Originally created by @lmagnien on GitHub (Mar 8, 2024).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Pleas do not modify this template :) and fill in all the required fields.

Dify version

0.5.8

Cloud or Self Hosted

Self Hosted (Docker), Self Hosted (Source)

Steps to reproduce

Set smtp username and/or smtp password value to empty string :

  MAIL_TYPE: 'smtp'
  # default send from email address, if not specified
  MAIL_DEFAULT_SEND_FROM: 'YOUR EMAIL FROM (eg: no-reply <no-reply@dify.ai>)'
  SMTP_SERVER: 'localhost'
  SMTP_PORT: 25
  SMTP_USERNAME: ''
  SMTP_PASSWORD: ''

✔️ Expected Behavior

If an SMTP server does not require authentication, you can leave the username and password fields blank.

Actual Behavior

A ValueError is raised due to this line in ext_mail.py :
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')

SMTP servers can be configured to use either authenticated or unauthenticated SMTP.
I can send you a small PR for this. Thanks for your work.

Originally created by @lmagnien on GitHub (Mar 8, 2024). ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Pleas do not modify this template :) and fill in all the required fields. ### Dify version 0.5.8 ### Cloud or Self Hosted Self Hosted (Docker), Self Hosted (Source) ### Steps to reproduce Set smtp username and/or smtp password value to empty string : MAIL_TYPE: 'smtp' # default send from email address, if not specified MAIL_DEFAULT_SEND_FROM: 'YOUR EMAIL FROM (eg: no-reply <no-reply@dify.ai>)' SMTP_SERVER: 'localhost' SMTP_PORT: 25 SMTP_USERNAME: '' SMTP_PASSWORD: '' ### ✔️ Expected Behavior If an SMTP server does not require authentication, you can leave the username and password fields blank. ### ❌ Actual Behavior A ValueError is raised due to this line in ext_mail.py : 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') SMTP servers can be configured to use either authenticated or unauthenticated SMTP. I can send you a small PR for this. Thanks for your work.
yindo added the 🐞 bug label 2026-02-21 17:31:45 -05:00
yindo closed this issue 2026-02-21 17:31:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#1277