From 0add257e90e15ca4babca0d18cfb6995693b810f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 11 Sep 2022 20:24:26 +0530 Subject: [PATCH] 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. --- src/calibre/gui2/email.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/calibre/gui2/email.py b/src/calibre/gui2/email.py index e5c3c166e5..f6e54aa1f3 100644 --- a/src/calibre/gui2/email.py +++ b/src/calibre/gui2/email.py @@ -153,16 +153,20 @@ def send_mails(jobnames, callback, attachments, to_s, subjects, for name, attachment, to, subject, text, aname in zip(jobnames, attachments, to_s, subjects, texts, attachment_names): description = _('Email %(name)s to %(to)s') % dict(name=name, to=to) - if isinstance(to, str): - if '@kindle.com' in to: - aname = ascii_filename(aname) - elif '@pbsync.com' in to: - # The PocketBook service is a total joke. It cant handle - # 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 - # containing only 22 English letters and numbers - from calibre.utils.short_uuid import uuid4 - aname = f'{uuid4()}.' + aname.rpartition('.')[-1] + if isinstance(to, str) and ('@kindle.com' in to or '@pbsync.com' in to): + # The PocketBook service is a total joke. It cant handle + # 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 + # containing only 22 English letters and numbers + # + # And since this email is only going to be processed by automated + # services, make the subject random too as at least the amazon + # service cant handle non-ascii subjects. I dont know what baboons + # 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, subject, text), {}, callback) job_manager.run_threaded_job(job)