filename for attached images (#19929)

This commit is contained in:
AAfghahi 2022-05-05 13:27:52 -04:00 committed by GitHub
parent 7b88ec7e25
commit 2e2053f72f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -928,7 +928,9 @@ def send_email_smtp( # pylint: disable=invalid-name,too-many-arguments,too-many
# Attach any inline images, which may be required for display in
# HTML content (inline)
for msgid, imgdata in (images or {}).items():
image = MIMEImage(imgdata)
formatted_time = formatdate(localtime=True)
file_name = f"{subject} {formatted_time}"
image = MIMEImage(imgdata, name=file_name)
image.add_header("Content-ID", "<%s>" % msgid)
image.add_header("Content-Disposition", "inline")
msg.attach(image)