From d4baeb0687ea99d8700dd0d06c1a9402ec68b289 Mon Sep 17 00:00:00 2001 From: AarDG10 Date: Sun, 22 Feb 2026 11:14:03 +0530 Subject: [PATCH] fix: skip sending mail if account does not exist --- frappe/core/doctype/user/user.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frappe/core/doctype/user/user.py b/frappe/core/doctype/user/user.py index ebaf8836cb..1c3fcac899 100644 --- a/frappe/core/doctype/user/user.py +++ b/frappe/core/doctype/user/user.py @@ -1459,7 +1459,8 @@ def impersonate(user: str, reason: str): notification.set("type", "Alert") notification.insert(ignore_permissions=True) # notify user via email too - if not frappe.conf.get("developer_mode"): # bypass for testing locally + email_exists = frappe.db.exists("Email Account", {"default_outgoing": 1, "awaiting_password": 0}) + if email_exists: user_email = frappe.db.get_value("User", user, "email") email_message = _( "User {0} has started an impersonation session as you.

Reason provided: {1}"