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:
Magicbook1108
2026-02-26 13:49:53 +08:00
committed by GitHub
parent 74dc43406f
commit 1aa49a11f0
14 changed files with 67 additions and 46 deletions

View File

@ -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)

View File

@ -1912,11 +1912,12 @@ The above is the content you need to summarize.`,
'Компонент, който форматира изхода на други компоненти. 1. Поддържа Jinja2 шаблони, 2. Едновременно запазва оригиналния метод за заместване на низове с {parameter}',
emailComponent: 'Имейл',
emailDescription: 'Изпращане на имейл до определен адрес.',
smtpServer: 'SMTP сървър',
smtpServer: 'SMTP хост',
smtpPort: 'SMTP порт',
senderEmail: 'Имейл на подателя',
authCode: 'Код за оторизация',
senderName: 'Име на подателя',
senderEmail: 'Адрес на подателя (From)',
smtpUsername: 'SMTP потребителско име',
authCode: 'SMTP парола / парола за приложение',
senderName: 'Показвано име на подателя',
toEmail: 'Имейл на получателя',
ccEmail: 'Копие до',
emailSubject: 'Тема',

View File

@ -1926,11 +1926,12 @@ Beispiel: Virtual Hosted Style`,
'Eine Komponente, die die Ausgabe anderer Komponenten formatiert. 1. Unterstützt Jinja2-Vorlagen, konvertiert zuerst die Eingabe in ein Objekt und rendert dann die Vorlage, 2. Behält gleichzeitig die ursprüngliche Methode der Verwendung von {parameter} Zeichenkettenersetzung bei',
emailComponent: 'E-Mail',
emailDescription: 'Sendet eine E-Mail an eine angegebene Adresse.',
smtpServer: 'SMTP-Server',
smtpServer: 'SMTP-Host',
smtpPort: 'SMTP-Port',
senderEmail: 'Absender-E-Mail',
authCode: 'Autorisierungscode',
senderName: 'Absendername',
senderEmail: 'Absenderadresse (From)',
smtpUsername: 'SMTP-Anmeldebenutzername',
authCode: 'SMTP-Passwort/App-Passwort',
senderName: 'Anzeigename des Absenders',
toEmail: 'Empfänger-E-Mail',
ccEmail: 'CC-E-Mail',
emailSubject: 'Betreff',

View File

@ -1904,11 +1904,12 @@ Example: Virtual Hosted Style`,
'A component that formats the output of other components.1. Supports Jinja2 templates, will first convert the input to an object and then render the template, 2. Simultaneously retains the original method of using {parameter} string replacement',
emailComponent: 'Email',
emailDescription: 'Send an email to a specified address.',
smtpServer: 'SMTP server',
smtpServer: 'SMTP host',
smtpPort: 'SMTP port',
senderEmail: 'Sender email',
authCode: 'Authorization code',
senderName: 'Sender name',
senderEmail: 'From email address',
smtpUsername: 'SMTP login username',
authCode: 'SMTP password / app password',
senderName: 'From display name',
toEmail: 'Recipient email',
ccEmail: 'CC email',
emailSubject: 'Subject',

View File

@ -1160,11 +1160,12 @@ export default {
'Un composant qui formate la sortie des autres composants. 1. Supporte les templates Jinja2, convertit dabord lentrée en objet puis rend le template, 2. Conserve en parallèle la méthode originale de remplacement de chaîne {parameter}',
emailComponent: 'Email',
emailDescription: 'Envoyer un email à une adresse spécifiée.',
smtpServer: 'Serveur SMTP',
smtpServer: 'Hôte SMTP',
smtpPort: 'Port SMTP',
senderEmail: 'Email de lexpéditeur',
authCode: 'Code dautorisation',
senderName: 'Nom de lexpéditeur',
senderEmail: 'Adresse dexpéditeur (From)',
smtpUsername: 'Nom dutilisateur SMTP',
authCode: 'Mot de passe SMTP / mot de passe dapplication',
senderName: 'Nom daffichage de lexpéditeur',
toEmail: 'Email du destinataire',
ccEmail: 'Email en copie',
emailSubject: 'Sujet',

View File

@ -1082,11 +1082,12 @@ Quanto sopra è il contenuto che devi riassumere.`,
"Un componente che formatta l'output di altri componenti.",
emailComponent: 'Email',
emailDescription: "Invia un'email a un indirizzo specificato.",
smtpServer: 'Server SMTP',
smtpServer: 'Host SMTP',
smtpPort: 'Porta SMTP',
senderEmail: 'Email mittente',
authCode: 'Codice autorizzazione',
senderName: 'Nome mittente',
senderEmail: 'Indirizzo mittente (From)',
smtpUsername: 'Nome utente di accesso SMTP',
authCode: 'Password SMTP / password app',
senderName: 'Nome visualizzato mittente',
toEmail: 'Email destinatario',
ccEmail: 'Email CC',
emailSubject: 'Oggetto',

View File

@ -1156,11 +1156,12 @@ export default {
'このコンポーネントは、さまざまなコンポーネントの出力を組版するために使用されます。1. Jinja2テンプレートをサポートし、最初に入力をオブジェクトに変換してからテンプレートをレンダリングします。2. {parameter}文字列置換を使用する元の方法も同時に保持します',
emailComponent: 'メール',
emailDescription: '指定されたアドレスにメールを送信',
smtpServer: 'SMTPサーバー',
smtpServer: 'SMTPホスト',
smtpPort: 'SMTPポート',
senderEmail: '送信者のメール',
authCode: '認証コード',
senderName: '送信者の名前',
senderEmail: '差出人メールアドレスFrom',
smtpUsername: 'SMTPログインユーザー名',
authCode: 'SMTPパスワード/アプリパスワード',
senderName: '差出人表示名',
toEmail: '受信者のメール',
ccEmail: 'CCメール',
emailSubject: '件名',

View File

@ -1132,11 +1132,12 @@ export default {
emailComponent: 'Email',
emailDescription: 'Enviar um email para um endereço especificado.',
smtpServer: 'Servidor SMTP',
smtpServer: 'Host SMTP',
smtpPort: 'Porta SMTP',
senderEmail: 'Email do remetente',
authCode: 'Código de autorização',
senderName: 'Nome do remetente',
senderEmail: 'Endereço do remetente (From)',
smtpUsername: 'Usuário de login SMTP',
authCode: 'Senha SMTP / senha de app',
senderName: 'Nome de exibição do remetente',
toEmail: 'Email do destinatário',
ccEmail: 'Email CC',
emailSubject: 'Assunto',

View File

@ -1624,11 +1624,12 @@ export default {
'Компонент, который форматирует вывод других компонентов.1. Поддерживает шаблоны Jinja2, сначала преобразует вход в объект, а затем рендерит шаблон, 2. Одновременно сохраняет исходный метод использования замены строки {parameter}',
emailComponent: 'Email',
emailDescription: 'Отправить email на указанный адрес.',
smtpServer: 'SMTP Сервер',
smtpPort: 'SMTP Порт',
senderEmail: 'Email отправителя',
authCode: 'Код авторизации',
senderName: 'Имя отправителя',
smtpServer: 'SMTP хост',
smtpPort: 'SMTP порт',
senderEmail: 'Адрес отправителя (From)',
smtpUsername: 'Имя пользователя SMTP',
authCode: 'Пароль SMTP / пароль приложения',
senderName: 'Отображаемое имя отправителя',
toEmail: 'Email получателя',
ccEmail: 'Email копии',
emailSubject: 'Тема',

View File

@ -1194,8 +1194,8 @@ export default {
toEmail: 'Email người nhận',
smtpServerRequired: 'Vui lòng nhập địa chỉ máy chủ SMTP',
emailContent: 'Nội dung',
smtpServer: 'SMTP Server',
smtpPort: 'SMTP Port',
smtpServer: 'Máy chủ SMTP',
smtpPort: 'Cổng SMTP',
senderEmailRequired: 'Vui lòng nhập email người gửi',
authCodeRequired: 'Vui lòng nhập mã xác thực',
toEmailRequired: 'Vui lòng nhập email người nhận',
@ -1205,9 +1205,10 @@ export default {
jsonFormatTip:
'Thành phần thượng nguồn phải cung cấp chuỗi JSON theo định dạng sau:',
emailComponent: 'Email',
senderEmail: 'Người gửi Email',
authCode: 'Mã xác minh',
senderName: 'Tên người gửi',
senderEmail: 'Địa chỉ người gửi (From)',
smtpUsername: 'Tên đăng nhập SMTP',
authCode: 'Mật khẩu SMTP / mật khẩu ứng dụng',
senderName: 'Tên hiển thị người gửi',
jsonUploadContentErrorMessage: 'lỗi tệp json',
contentTip: 'content: Nội dung email (Tùy chọn)',
subjectTip: 'subject: Tiêu đề email (Tùy chọn)',

View File

@ -1728,11 +1728,12 @@ General实体和关系提取提示来自 GitHub - microsoft/graphrag基于
'该组件用于排版各种组件的输出。1、支持Jinja2模板,会先将输入转为对象后进行模版渲染2、同时保留原使用{参数}字符串替换的方式',
emailComponent: '邮件',
emailDescription: '发送邮件到指定邮箱',
smtpServer: 'SMTP服务器',
smtpPort: 'SMTP端口',
senderEmail: '发件邮箱',
authCode: '授权码',
senderName: '发件人名称',
smtpServer: 'SMTP服务器地址',
smtpPort: 'SMTP端口',
senderEmail: '发件邮箱地址From',
smtpUsername: 'SMTP登录用户名',
authCode: 'SMTP登录密码/授权码',
senderName: '发件人显示名称',
toEmail: '收件人邮箱',
ccEmail: '抄送邮箱',
emailSubject: '邮件主题',

View File

@ -390,6 +390,7 @@ export const initialEmailValues = {
smtp_server: '',
smtp_port: 465,
email: '',
smtp_username: '',
password: '',
sender_name: '',
to_email: '',

View File

@ -86,6 +86,10 @@ export function EmailFormWidgets() {
type="number"
></InputFormField>
<InputFormField name="email" label={t('senderEmail')}></InputFormField>
<InputFormField
name="smtp_username"
label={t('smtpUsername')}
></InputFormField>
<InputFormField
name="password"
label={t('authCode')}
@ -103,6 +107,7 @@ export const EmailFormPartialSchema = {
smtp_server: z.string(),
smtp_port: z.number(),
email: z.string(),
smtp_username: z.string(),
password: z.string(),
sender_name: z.string(),
};

View File

@ -33,6 +33,7 @@ export function useAgentToolInitialValues() {
'smtp_server',
'smtp_port',
'email',
'smtp_username',
'password',
'sender_name',
);