Merge pull request #891 from nitr0man/0.2.x

Fix Exception on sending mails with ticket attaches for non-file storages
This commit is contained in:
Garret Wassermann 2020-10-19 17:09:58 -04:00 committed by GitHub
commit 8bd772db9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,17 +123,7 @@ def send_templated_mail(template_name,
if files:
for filename, filefield in files:
mime = mimetypes.guess_type(filename)
if mime[0] is not None and mime[0] == "text/plain":
with open(filefield.path, 'r') as attachedfile:
content = attachedfile.read()
msg.attach(filename, content)
else:
if six.PY3:
msg.attach_file(filefield.path)
else:
with open(filefield.path, 'rb') as attachedfile:
content = attachedfile.read()
content = filefield.read()
msg.attach(filename, content)
logger.debug('Sending email to: {!r}'.format(recipients))