diff --git a/cps/helper.py b/cps/helper.py index 7fc2edc9..9771c2fe 100644 --- a/cps/helper.py +++ b/cps/helper.py @@ -223,9 +223,11 @@ def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id) converted_file_name = entry.name + '.' + book_format.lower() link = '{}'.format(url_for('web.show_book', book_id=book_id), escape(book.title)) email_text = N_("%(book)s send to eReader", book=link) - WorkerThread.add(user_id, TaskEmail(_("Send to eReader"), book.path, converted_file_name, - config.get_mail_settings(), ereader_mail, - email_text, _('This Email has been sent via Calibre-Web.'))) + WorkerThread.add(user_id, TaskEmail(_(u"Send to E-Reader"), book.path, converted_file_name, + config.get_mail_settings(), ereader_mail, + email_text, _(u'This e-mail has been sent via Calibre-Web.'), + False, + str(book.title.encode('utf-8'), 'utf-8') + '.' + book_format.lower())) return return _("The requested file could not be read. Maybe wrong permissions?") diff --git a/cps/tasks/mail.py b/cps/tasks/mail.py index a7f0c2ec..100e4883 100755 --- a/cps/tasks/mail.py +++ b/cps/tasks/mail.py @@ -109,7 +109,8 @@ class EmailSSL(EmailBase, smtplib.SMTP_SSL): class TaskEmail(CalibreTask): - def __init__(self, subject, filepath, attachment, settings, recipient, task_message, text, internal=False): + def __init__(self, subject, filepath, attachment, settings, recipient, task_message, text, internal=False + , display_name=""): super(TaskEmail, self).__init__(task_message) self.subject = subject self.attachment = attachment @@ -119,6 +120,9 @@ class TaskEmail(CalibreTask): self.text = text self.asyncSMTP = None self.results = dict() + if display_name == "": + display_name = attachment + self.display_name = display_name # from calibre code: # https://github.com/kovidgoyal/calibre/blob/731ccd92a99868de3e2738f65949f19768d9104c/src/calibre/utils/smtp.py#L60 @@ -150,7 +154,7 @@ class TaskEmail(CalibreTask): if content_type is None or encoding is not None: content_type = 'application/octet-stream' main_type, sub_type = content_type.split('/', 1) - message.add_attachment(data, maintype=main_type, subtype=sub_type, filename=self.attachment) + message.add_attachment(data, maintype=main_type, subtype=sub_type, filename=self.display_name) else: self._handleError("Attachment not found") return