Cannot send email from Document with Attachment as regular user - Not showing to Email Queue

My problem is I cannot send email as a regular user. However, as admin user, I can send emails just fine.

How to reproduce:

  1. The regular user has permissions: Employee, Inbox User, Accounts User, Purchase Manager
  2. In “User Emails”, add the Email Account needed
  3. Get a Purchase Invoice document to send. This document has an attachment uploaded by the admin, and the attachment is set public (Is Private unchecked).
  4. Use “…” > “Email” to send the document, choose the From email account, check enable attachment, then click Send. --> NO Error message, and the “email” is added to the Activities section below the document
  5. However, Email is never added to Email Queue, and never sent

When the above is done from a user with “System Manager” privileges, the email can get added to the Email Queue and sent correctly.

What step did I miss?

Similar issue: Emails not sendng

I thought maybe this is the issue: From Send emails from ERPNext from own account by @umair :

To allow Users to send emails from your ERPNext account, you should ensure that Roles assigned to those Users also cover Email permission on that Doctype.

Update: It seems this is not the issue, as the user:

  • tries to send Purchase Invoice document
  • has roles of Accounts User (which allows Email-ing Purchase Invoice) and also Purchase Manager

If the “Email” permission is not given in the role, then the “Email” menu item will not be shown in the first place.

It could be the attachment? I check the Error Log List and found this:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 100, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 461, in sendmail
    communication._notify(print_html=print_html, print_format=print_format, attachments=attachments,
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/communication.py", line 211, in _notify
    _notify(self, print_html, print_format, attachments, recipients, cc, bcc)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 151, in _notify
    prepare_to_notify(doc, print_html, print_format, attachments)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/communication/email.py", line 262, in prepare_to_notify
    frappe.throw(_("Unable to find attachment {0}").format(a))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 424, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 403, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 357, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.ValidationError: Unable to find attachment f8f88a193d

Update: YES this is the cause.

But why did this happen?

The attachment file is not shared to the regular user. But the file itself is not private, and user already has access to the “parent” document, which is the Purchase Invoice.

I’d expect that all the files attached there, automatically is accessible by these users.

Is this a bug or designed feature?

If it works as designed, what is the best way to do this, without sharing explicitly each attachment to the “email sender” user?

Also, the bug is, if the attachment privilege is denied, then error should be shown interactively right when Sending the email (and thus, cannot continue). Instead of “pretending” the email is sent and added to Activities and never sent.

Related issues:

2 Likes