mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-12-01 20:33:12 +01:00
fix files attaching to emails for remote storages
Storages like S3, Dropbox, etc have no filefield.path() method - so submitting ticket with attachment leads to exception
This commit is contained in:
parent
b126ccc7b8
commit
22c07aa18b
@ -123,18 +123,8 @@ def send_templated_mail(template_name,
|
|||||||
|
|
||||||
if files:
|
if files:
|
||||||
for filename, filefield in files:
|
for filename, filefield in files:
|
||||||
mime = mimetypes.guess_type(filename)
|
content = filefield.read()
|
||||||
if mime[0] is not None and mime[0] == "text/plain":
|
msg.attach(filename, content)
|
||||||
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()
|
|
||||||
msg.attach(filename, content)
|
|
||||||
|
|
||||||
logger.debug('Sending email to: {!r}'.format(recipients))
|
logger.debug('Sending email to: {!r}'.format(recipients))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user