pull/2695/merge
huyumars 3 months ago committed by GitHub
commit 0c06dbce45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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 = '<a href="{}">{}</a>'.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?")

@ -110,7 +110,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
@ -120,6 +121,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
@ -151,7 +155,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

Loading…
Cancel
Save