How to config mail in .env.example pls help me to give a example thanks very much #8323

Closed
opened 2026-02-21 18:25:05 -05:00 by yindo · 6 comments
Owner

Originally created by @sukai-cheng on GitHub (Feb 17, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • 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).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.3

Cloud or Self Hosted

Self Hosted (Source), Self Hosted (Docker)

Steps to reproduce

pls give me a example
Image

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @sukai-cheng on GitHub (Feb 17, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [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] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.15.3 ### Cloud or Self Hosted Self Hosted (Source), Self Hosted (Docker) ### Steps to reproduce pls give me a example <img width="1728" alt="Image" src="https://github.com/user-attachments/assets/d5a5821b-72fd-4adf-9f69-51f43badb24f" /> ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🙋‍♂️ question label 2026-02-21 18:25:05 -05:00
yindo closed this issue 2026-02-21 18:25:05 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 17, 2025):

Hello @sukai-cheng! I'm here to help you with any bugs, questions, or contributions. Let me know how I can assist you!

To configure mail settings in the .env.example file for Dify, you can use the following example configuration:

# Mail type, support: resend, smtp
MAIL_TYPE=smtp

# Default send from email address, if not specified
MAIL_DEFAULT_SEND_FROM=no-reply <no-reply@dify.ai>

# SMTP server configuration, used when MAIL_TYPE is `smtp`
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=465
SMTP_USERNAME=your-email@gmail.com
SMTP_PASSWORD=your-email-password
SMTP_USE_TLS=true
SMTP_OPPORTUNISTIC_TLS=false

In this example, the MAIL_TYPE is set to smtp, and the SMTP server details are configured for Gmail. Replace your-email@gmail.com and your-email-password with your actual email and password. Ensure that MAIL_DEFAULT_SEND_FROM is set to the desired default sender email address [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Feb 17, 2025): <!-- Greeting --> Hello @sukai-cheng! I'm here to help you with any bugs, questions, or contributions. Let me know how I can assist you! <!-- Answer --> To configure mail settings in the `.env.example` file for Dify, you can use the following example configuration: ```plaintext # Mail type, support: resend, smtp MAIL_TYPE=smtp # Default send from email address, if not specified MAIL_DEFAULT_SEND_FROM=no-reply <no-reply@dify.ai> # SMTP server configuration, used when MAIL_TYPE is `smtp` SMTP_SERVER=smtp.gmail.com SMTP_PORT=465 SMTP_USERNAME=your-email@gmail.com SMTP_PASSWORD=your-email-password SMTP_USE_TLS=true SMTP_OPPORTUNISTIC_TLS=false ``` In this example, the `MAIL_TYPE` is set to `smtp`, and the SMTP server details are configured for Gmail. Replace `your-email@gmail.com` and `your-email-password` with your actual email and password. Ensure that `MAIL_DEFAULT_SEND_FROM` is set to the desired default sender email address <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/.env.example)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/61477100-75ba-46b6-a52e-578c36bb1feb?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/61477100-75ba-46b6-a52e-578c36bb1feb?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/61477100-75ba-46b6-a52e-578c36bb1feb?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/61477100-75ba-46b6-a52e-578c36bb1feb?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/61477100-75ba-46b6-a52e-578c36bb1feb?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/61477100-75ba-46b6-a52e-578c36bb1feb?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/61477100-75ba-46b6-a52e-578c36bb1feb?feedback_type=other)</sup>
Author
Owner

@sukai-cheng commented on GitHub (Feb 17, 2025):

thanks, i really done config it, why can't send , i'm cursously

Image
@sukai-cheng commented on GitHub (Feb 17, 2025): thanks, i really done config it, why can't send , i'm cursously <img width="941" alt="Image" src="https://github.com/user-attachments/assets/7215651a-f538-486d-8e6d-0c0a7c2e4120" />
Author
Owner

@crazywoola commented on GitHub (Feb 17, 2025):

This is only for bug report, if you would like to ask a question, please head to Discussions.

If you can not send the email, there should be some error logs. Please provide them.

@crazywoola commented on GitHub (Feb 17, 2025): This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). If you can not send the email, there should be some error logs. Please provide them.
Author
Owner

@sukai-cheng commented on GitHub (Feb 17, 2025):

thanks i hava solved it

@sukai-cheng commented on GitHub (Feb 17, 2025): thanks i hava solved it
Author
Owner

@msrdjan commented on GitHub (Feb 24, 2025):

I have tried configuring both smtp and resend blocks:

# ------------------------------
# Mail related configuration
# ------------------------------

# Mail type, support: resend, smtp
MAIL_TYPE=resend

# Default send from email address, if not specified
MAIL_DEFAULT_SEND_FROM=no-reply <no-reply@redacted>

# API-Key for the Resend email provider, used when MAIL_TYPE is `resend`.
RESEND_API_URL=https://api.resend.com/
RESEND_API_KEY=re_N...mKs (redacted)


# SMTP server configuration, used when MAIL_TYPE is `smtp`
SMTP_SERVER=smtp.eu.mailgun.org
SMTP_PORT=587
SMTP_USERNAME=no-reply@redacted
SMTP_PASSWORD=f2b...745 (redacted)
SMTP_USE_TLS=true
SMTP_OPPORTUNISTIC_TLS=false

and restarting containers using:

docker compose restart

But I'm constantly getting this error:

docker-worker-1  | 2025-02-24 19:17:01.001 INFO [Dummy-2] [mail_reset_password_task.py:22] - Start password reset mail to <redacted>
docker-worker-1  | 2025-02-24 19:17:01.003 ERROR [Dummy-2] [mail_reset_password_task.py:41] - Send password reset mail to <redacted>
docker-worker-1  | Traceback (most recent call last):
docker-worker-1  |   File "/app/api/tasks/mail_reset_password_task.py", line 32, in send_reset_password_mail_task
docker-worker-1  |     mail.send(to=to, subject="Set Your Dify Password", html=html_content)
docker-worker-1  |   File "/app/api/extensions/ext_mail.py", line 68, in send
docker-worker-1  |     raise ValueError("mail from is not set")
docker-worker-1  | ValueError: mail from is not set
@msrdjan commented on GitHub (Feb 24, 2025): I have tried configuring both `smtp` and `resend` blocks: ```ini # ------------------------------ # Mail related configuration # ------------------------------ # Mail type, support: resend, smtp MAIL_TYPE=resend # Default send from email address, if not specified MAIL_DEFAULT_SEND_FROM=no-reply <no-reply@redacted> # API-Key for the Resend email provider, used when MAIL_TYPE is `resend`. RESEND_API_URL=https://api.resend.com/ RESEND_API_KEY=re_N...mKs (redacted) # SMTP server configuration, used when MAIL_TYPE is `smtp` SMTP_SERVER=smtp.eu.mailgun.org SMTP_PORT=587 SMTP_USERNAME=no-reply@redacted SMTP_PASSWORD=f2b...745 (redacted) SMTP_USE_TLS=true SMTP_OPPORTUNISTIC_TLS=false ``` and restarting containers using: ```shell docker compose restart ``` But I'm constantly getting this error: ```log docker-worker-1 | 2025-02-24 19:17:01.001 INFO [Dummy-2] [mail_reset_password_task.py:22] - Start password reset mail to <redacted> docker-worker-1 | 2025-02-24 19:17:01.003 ERROR [Dummy-2] [mail_reset_password_task.py:41] - Send password reset mail to <redacted> docker-worker-1 | Traceback (most recent call last): docker-worker-1 | File "/app/api/tasks/mail_reset_password_task.py", line 32, in send_reset_password_mail_task docker-worker-1 | mail.send(to=to, subject="Set Your Dify Password", html=html_content) docker-worker-1 | File "/app/api/extensions/ext_mail.py", line 68, in send docker-worker-1 | raise ValueError("mail from is not set") docker-worker-1 | ValueError: mail from is not set ```
Author
Owner

@msrdjan commented on GitHub (Feb 24, 2025):

Looks like the configuration updates doesn't get applied with:

docker compose restart

So I tried using:

docker compose down
docker compose up -d

and it looks like it helps.

@msrdjan commented on GitHub (Feb 24, 2025): Looks like the configuration updates doesn't get applied with: ```shell docker compose restart ``` So I tried using: ```shell docker compose down docker compose up -d ``` and it looks like it helps.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8323