From c41cbd30dc429804413a1919f31bf5abce9792bf Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Mon, 5 Jan 2026 22:55:14 +0100 Subject: [PATCH] fix: properly check email send result in admin test endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit send_raw() returns EmailLog, not boolean - check status=="sent" and return error_message on failure instead of always reporting success. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- app/api/v1/admin/settings.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/api/v1/admin/settings.py b/app/api/v1/admin/settings.py index 8f4bf670..6e2e8411 100644 --- a/app/api/v1/admin/settings.py +++ b/app/api/v1/admin/settings.py @@ -659,7 +659,7 @@ def send_test_email( email_service = EmailService(db) # Send test email using platform configuration - success = email_service.send_raw( + email_log = email_service.send_raw( to_email=request.to_email, to_name=None, subject="Wizamart Platform - Test Email", @@ -684,7 +684,8 @@ def send_test_email( is_platform_email=True, ) - if success: + # Check if email was actually sent (send_raw returns EmailLog, not boolean) + if email_log.status == "sent": # Log action admin_audit_service.log_action( db=db, @@ -703,7 +704,7 @@ def send_test_email( else: return TestEmailResponse( success=False, - message="Failed to send test email. Check server logs for details.", + message=email_log.error_message or "Failed to send test email. Check server logs for details.", ) except Exception as e: