Fix #1989282 [Cannot email to Kindle after release 5.29](https://bugs.launchpad.net/calibre/+bug/1989282)

At least I hope. Who knows what amazon's stupid email service barfs on.
This commit is contained in:
Kovid Goyal 2022-09-11 20:24:26 +05:30
parent dfdb79a3ae
commit 0add257e90
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -153,16 +153,20 @@ def send_mails(jobnames, callback, attachments, to_s, subjects,
for name, attachment, to, subject, text, aname in zip(jobnames, for name, attachment, to, subject, text, aname in zip(jobnames,
attachments, to_s, subjects, texts, attachment_names): attachments, to_s, subjects, texts, attachment_names):
description = _('Email %(name)s to %(to)s') % dict(name=name, to=to) description = _('Email %(name)s to %(to)s') % dict(name=name, to=to)
if isinstance(to, str): if isinstance(to, str) and ('@kindle.com' in to or '@pbsync.com' in to):
if '@kindle.com' in to: # The PocketBook service is a total joke. It cant handle
aname = ascii_filename(aname) # non-ascii, filenames that are long enough to be split up, commas, and
elif '@pbsync.com' in to: # the good lord alone knows what else. So use a random filename
# The PocketBook service is a total joke. It cant handle # containing only 22 English letters and numbers
# non-ascii, filenames that are long enough to be split up, commas, and #
# the good lord alone knows what else. So use a random filename # And since this email is only going to be processed by automated
# containing only 22 English letters and numbers # services, make the subject random too as at least the amazon
from calibre.utils.short_uuid import uuid4 # service cant handle non-ascii subjects. I dont know what baboons
aname = f'{uuid4()}.' + aname.rpartition('.')[-1] # these companies employ to write their code. It's the height of
# irony that they are called "tech" companies.
from calibre.utils.short_uuid import uuid4
aname = f'{uuid4()}.' + aname.rpartition('.')[-1]
subject = uuid4()
job = ThreadedJob('email', description, gui_sendmail, (attachment, aname, to, job = ThreadedJob('email', description, gui_sendmail, (attachment, aname, to,
subject, text), {}, callback) subject, text), {}, callback)
job_manager.run_threaded_job(job) job_manager.run_threaded_job(job)