mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-05-06 02:07:49 +08:00
Feat: support AWS SES smtp (#13195)
### What problem does this PR solve? Support AWS SES smtp #13179 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -68,6 +68,7 @@ class EmailParam(ToolParamBase):
|
||||
self.smtp_server = "" # SMTP server address
|
||||
self.smtp_port = 465 # SMTP port
|
||||
self.email = "" # Sender email
|
||||
self.smtp_username = "" # Optional SMTP login username, fallback to sender email
|
||||
self.password = "" # Email authorization code
|
||||
self.sender_name = "" # Sender name
|
||||
|
||||
@ -96,6 +97,7 @@ class EmailParam(ToolParamBase):
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class Email(ToolBase, ABC):
|
||||
component_name = "Email"
|
||||
|
||||
@ -149,9 +151,11 @@ class Email(ToolBase, ABC):
|
||||
server.ehlo()
|
||||
server.starttls(context=context)
|
||||
server.ehlo()
|
||||
|
||||
# Login
|
||||
logging.info(f"Attempting to login with email: {self._param.email}")
|
||||
server.login(self._param.email, self._param.password)
|
||||
smtp_username = self._param.smtp_username or self._param.email
|
||||
logging.info(f"Attempting to login with username: {smtp_username}")
|
||||
server.login(smtp_username, self._param.password)
|
||||
|
||||
# Get all recipient list
|
||||
recipients = [email_data["to_email"]]
|
||||
@ -190,7 +194,7 @@ class Email(ToolBase, ABC):
|
||||
return False
|
||||
|
||||
except smtplib.SMTPAuthenticationError:
|
||||
error_msg = "SMTP Authentication failed. Please check your email and authorization code."
|
||||
error_msg = "SMTP Authentication failed. Please check your SMTP username(email) and authorization code."
|
||||
logging.error(error_msg)
|
||||
self.set_output("_ERROR", error_msg)
|
||||
self.set_output("success", False)
|
||||
|
||||
Reference in New Issue
Block a user