Skip to content

Commit

Permalink
#1369 try to guess if file is an image
Browse files Browse the repository at this point in the history
  • Loading branch information
andreleblanc11 committed Jan 16, 2025
1 parent d9d75a7 commit 8ecc243
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sarracenia/flowcb/send/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
from email.mime.multipart import MIMEMultipart
from email.mime.application import MIMEApplication
from email.mime.text import MIMEText
import mimetypes
import logging
import os.path
import re
Expand Down Expand Up @@ -146,10 +147,12 @@ def send(self, msg):
# Get list of recipients for this message, from the mask that matched the filename/path
recipients = self.o.masks[msg['_mask_index']][-1]

file_type = mimetypes.guess_type(ipath)

# Prepare the email message
try:
if self.o.email_attachment:
# Build a non-text email message for the attachment.
# Build a non-text email message for the attachment if specified or if the file type can be deemed to be an image.
if self.o.email_attachment or 'image' in file_type[0]:
emsg = MIMEMultipart()
emsg_text = MIMEText(f"{self.o.email_attachment_text}")
# Add the attachment text that will be paired with the attachment data
Expand Down

0 comments on commit 8ecc243

Please sign in to comment.