Agent Zero AI framework
fix: test connection authenticates only, no email sent to avoid agent self-reply loop
linuztx3d9f5a846b8a
diff --git a/plugins/_email_integration/api/test_connection.py b/plugins/_email_integration/api/test_connection.pyindex 8daa70d7e..9a32d20bd 100644--- a/plugins/_email_integration/api/test_connection.py+++ b/plugins/_email_integration/api/test_connection.py@@ -8,7 +8,7 @@ from plugins._email_integration.helpers.imap_client import (disconnect_imap,get_highest_uid,)-from plugins._email_integration.helpers.smtp_client import SmtpConfig, send_reply+from plugins._email_integration.helpers.smtp_client import SmtpConfig, test_smtpclass TestConnection(ApiHandler):@@ -56,19 +56,14 @@ class TestConnection(ApiHandler):username=handler.get("username", ""),password=handler.get("password", ""),)- error = await send_reply(- config=cfg,- to=handler.get("username", ""),- subject="Agent Zero - Connection Test",- body="SMTP connection test successful.",- )+ error = await test_smtp(cfg)if error:results.append({"test": "SMTP", "ok": False, "message": error})else:results.append({"test": "SMTP","ok": True,- "message": "Connected, test email sent to self",+ "message": "Authenticated successfully",})except Exception as e:results.append({diff --git a/plugins/_email_integration/helpers/smtp_client.py b/plugins/_email_integration/helpers/smtp_client.pyindex fc8fbba64..462227662 100644--- a/plugins/_email_integration/helpers/smtp_client.py+++ b/plugins/_email_integration/helpers/smtp_client.py@@ -87,3 +87,28 @@ async def send_reply(error = format_error(e)PrintStyle.error(f"Email send failed: {error}")return error+++# ------------------------------------------------------------------+# Connection test (auth only, no email sent)+# ------------------------------------------------------------------++async def test_smtp(config: SmtpConfig) -> str | None:+ loop = asyncio.get_event_loop()++ def _sync_test():+ if config.use_tls:+ with smtplib.SMTP(config.server, config.port) as server:+ server.ehlo()+ server.starttls()+ server.ehlo()+ server.login(config.username, config.password)+ else:+ with smtplib.SMTP_SSL(config.server, config.port) as server:+ server.login(config.username, config.password)++ try:+ await loop.run_in_executor(None, _sync_test)+ return None+ except Exception as e:+ return format_error(e)