diff --git a/frappe/core/doctype/user/user.py b/frappe/core/doctype/user/user.py
index 850fde97fc..37abbcca91 100644
--- a/frappe/core/doctype/user/user.py
+++ b/frappe/core/doctype/user/user.py
@@ -1468,9 +1468,7 @@ def impersonate(user: str, reason: str):
"User {0} has started an impersonation session as you.
Reason provided: {1}"
).format(escape_html(impersonator), escape_html(reason))
- frappe.enqueue(
- method="frappe.sendmail",
- queue="short",
+ frappe.sendmail(
recipients=[user_email],
subject=_("Security Alert: Your account is being impersonated"),
content=email_message,
diff --git a/frappe/tests/test_email.py b/frappe/tests/test_email.py
index f47d4af099..788fe1e476 100644
--- a/frappe/tests/test_email.py
+++ b/frappe/tests/test_email.py
@@ -318,15 +318,14 @@ class TestEmail(IntegrationTestCase):
frappe.get_doc({"doctype": "User", "email": target_user, "first_name": "Target"}).insert(
ignore_permissions=True
)
- with patch("frappe.enqueue") as mocked_enqueue:
- reason = "Testing Security Alert"
- impersonate(user=target_user, reason=reason)
-
- self.assertEqual(frappe.session.user, target_user) # test if impersonation worked
- _, kwargs = mocked_enqueue.call_args
- self.assertEqual(kwargs.get("method"), "frappe.sendmail") # test if email was enqueued
- self.assertIn(target_user, kwargs.get("recipients"))
- self.assertIn(reason, kwargs.get("content"))
+ reason = "Testing Security Alert"
+ impersonate(user=target_user, reason=reason)
+ self.assertEqual(frappe.session.user, target_user) # test if impersonation worked
+ self.assertTrue(frappe.db.exists("Activity Log", {"user": target_user, "operation": "Impersonate"}))
+ email_queued = frappe.db.exists(
+ "Email Queue Recipient", {"recipient": target_user, "status": "Not Sent"}
+ )
+ self.assertTrue(email_queued, f"Impersonation email was not queued for {target_user}")
frappe.db.delete("User", {"email": target_user})