mirror of
https://github.com/janeczku/calibre-web
synced 2024-09-27 22:58:22 +00:00
Merge 436dd59c10
into b38a1b2298
This commit is contained in:
commit
0c06dbce45
@ -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()
|
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))
|
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)
|
email_text = N_("%(book)s send to eReader", book=link)
|
||||||
WorkerThread.add(user_id, TaskEmail(_("Send to eReader"), book.path, converted_file_name,
|
WorkerThread.add(user_id, TaskEmail(_(u"Send to E-Reader"), book.path, converted_file_name,
|
||||||
config.get_mail_settings(), ereader_mail,
|
config.get_mail_settings(), ereader_mail,
|
||||||
email_text, _('This Email has been sent via Calibre-Web.')))
|
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
|
||||||
return _("The requested file could not be read. Maybe wrong permissions?")
|
return _("The requested file could not be read. Maybe wrong permissions?")
|
||||||
|
|
||||||
|
@ -110,7 +110,8 @@ class EmailSSL(EmailBase, smtplib.SMTP_SSL):
|
|||||||
|
|
||||||
|
|
||||||
class TaskEmail(CalibreTask):
|
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)
|
super(TaskEmail, self).__init__(task_message)
|
||||||
self.subject = subject
|
self.subject = subject
|
||||||
self.attachment = attachment
|
self.attachment = attachment
|
||||||
@ -120,6 +121,9 @@ class TaskEmail(CalibreTask):
|
|||||||
self.text = text
|
self.text = text
|
||||||
self.asyncSMTP = None
|
self.asyncSMTP = None
|
||||||
self.results = dict()
|
self.results = dict()
|
||||||
|
if display_name == "":
|
||||||
|
display_name = attachment
|
||||||
|
self.display_name = display_name
|
||||||
|
|
||||||
# from calibre code:
|
# from calibre code:
|
||||||
# https://github.com/kovidgoyal/calibre/blob/731ccd92a99868de3e2738f65949f19768d9104c/src/calibre/utils/smtp.py#L60
|
# 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:
|
if content_type is None or encoding is not None:
|
||||||
content_type = 'application/octet-stream'
|
content_type = 'application/octet-stream'
|
||||||
main_type, sub_type = content_type.split('/', 1)
|
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:
|
else:
|
||||||
self._handleError("Attachment not found")
|
self._handleError("Attachment not found")
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user