mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-05-23 02:40:44 +02:00
Attachement should be readed in binary mode ... and attached as payload (regarding docs)
This commit is contained in:
parent
e7c4131ed7
commit
9939f62ebd
@ -118,11 +118,14 @@ def send_templated_mail(template_name,
|
|||||||
sender or settings.DEFAULT_FROM_EMAIL,
|
sender or settings.DEFAULT_FROM_EMAIL,
|
||||||
recipients, bcc=bcc)
|
recipients, bcc=bcc)
|
||||||
msg.attach_alternative(html_part, "text/html")
|
msg.attach_alternative(html_part, "text/html")
|
||||||
|
|
||||||
if files:
|
if files:
|
||||||
for file_name, file_field in files:
|
for file_name, file_field in files:
|
||||||
with open(file_field.path, 'rb') as attached_file:
|
part_attachment = MIMEBase('application', "octet-stream")
|
||||||
msg.attach(file_name, attached_file.read(), getattr(attached_file, 'content_type', None))
|
part_attachment.set_payload(open(file_field.path, 'rb').read())
|
||||||
|
encoders.encode_base64(part_attachment)
|
||||||
|
part_attachment.add_header('Content-Disposition', 'attachment; filename="{}"'.format(file_name))
|
||||||
|
msg.attach(part_attachment)
|
||||||
|
|
||||||
return msg.send(fail_silently)
|
return msg.send(fail_silently)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user