The inline_images parameter is passed but not used in the email sending function.
The issue involves the frappe.sendmail function ignoring the inline_images parameter, instead reading images from disk. The fix requires modifying the set_part_html function to use the passed inline_images parameter rather than reading from disk, which affects multi-tenant applications.
In frappe/email/email_body.py, the set_part_html function receives inline_images but never uses it:
def set_part_html(self, message, inline_images): # inline_images is passed
has_inline_images = EMBED_PATTERN.search(message)
if has_inline_images:
message, _inline_images = replace_filename_with_cid(message) # reads from disk
for image in _inline_images: # uses disk-read images
self.add_attachment(...)
it should pick the inline_images from the param passed and not try to read from disk to support multi-tenant apps and image stored in different sites. Currently it relies only on local disk to read the image.
Output of bench version
5.25.9
inline_images = [{ "filename": "files/logo.png", "filecontent": open("/path/to/logo.png", "rb").read(), }]
frappe.sendmail(
recipients=["[email protected]"],
subject="Test",
template="my_template", # contains
args={},
inline_images=inline_im
Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!