diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index bc4e4d869c0..f382118042a 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -364,13 +364,18 @@ class Project(Document): ) for user in self.users: + # process only users who haven't received the welcome email yet if user.welcome_email_sent == 0: - frappe.sendmail( - user.user, - subject=_("Project Collaboration Invitation"), - content=content, - ) - user.welcome_email_sent = 1 + # fetch canonical User data (enabled status + latest email) + user_info = frappe.db.get_value("User", user.user, ["enabled", "email"], as_dict=True) + # send email only if user is enabled and has a valid email + if user_info and user_info.enabled and user_info.email: + frappe.sendmail( + recipients=[user_info.email], + subject=_("Project Collaboration Invitation"), + content=content, + ) + user.welcome_email_sent = 1 def get_timeline_data(doctype: str, name: str) -> dict[int, int]: