api smtp error #3565

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

Originally created by @pt-cc on GitHub (May 22, 2024).

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).
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.8

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

https://github.com/langgenius/dify/blame/0.6.8/api/libs/smtp.py

cat libs/smtp.py
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText


class SMTPClient:
    def __init__(self, server: str, port: int, username: str, password: str, _from: str, use_tls=False):
        self.server = server
        self.port = port
        self._from = _from
        self.username = username
        self.password = password
        self._use_tls = use_tls

    def send(self, mail: dict):
        smtp = smtplib.SMTP(self.server, self.port)
        if self._use_tls:
            smtp.starttls()
        if self.username and self.password:
            smtp.login(self.username, self.password)
        msg = MIMEMultipart()
        msg['Subject'] = mail['subject']
        msg['From'] = self._from
        msg['To'] = mail['to']
        msg.attach(MIMEText(mail['html'], 'html'))
        smtp.sendmail(self.username, mail['to'], msg.as_string())
        smtp.quit()

其中的

smtp.sendmail(self.username, mail['to'], msg.as_string())  代码有问题,应该是
smtp.sendmail(self._from, mail['to'], msg.as_string())

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @pt-cc on GitHub (May 22, 2024). ### Self Checks - [ ] 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). - [ ] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [ ] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [ ] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.8 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce https://github.com/langgenius/dify/blame/0.6.8/api/libs/smtp.py ``` cat libs/smtp.py import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText class SMTPClient: def __init__(self, server: str, port: int, username: str, password: str, _from: str, use_tls=False): self.server = server self.port = port self._from = _from self.username = username self.password = password self._use_tls = use_tls def send(self, mail: dict): smtp = smtplib.SMTP(self.server, self.port) if self._use_tls: smtp.starttls() if self.username and self.password: smtp.login(self.username, self.password) msg = MIMEMultipart() msg['Subject'] = mail['subject'] msg['From'] = self._from msg['To'] = mail['to'] msg.attach(MIMEText(mail['html'], 'html')) smtp.sendmail(self.username, mail['to'], msg.as_string()) smtp.quit() ``` 其中的 ``` smtp.sendmail(self.username, mail['to'], msg.as_string()) 代码有问题,应该是 smtp.sendmail(self._from, mail['to'], msg.as_string()) ``` ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug label 2026-02-21 17:59:21 -05:00
yindo closed this issue 2026-02-21 17:59:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#3565