When sending emails to amazon and pocketbook use random english text instead of UUIDs for subject/body

Might workaround amazons latest attempt at blocking emails from calibre.
See #2110400 (Amazon blocking calibre mails sendtokindle)
This commit is contained in:
Kovid Goyal 2025-05-12 04:20:08 +05:30
parent e1bf592824
commit 43912e02bc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 18 additions and 2 deletions

View File

@ -170,8 +170,13 @@ def send_mails(jobnames, callback, attachments, to_s, subjects,
# file internal metadata so don't nuke the filename.
# https://www.mobileread.com/forums/showthread.php?t=349290
aname = f'{uuid4()}.' + aname.rpartition('.')[-1]
subject = uuid4()
text = uuid4()
import random
from calibre.utils.random_ua import common_english_words, random_english_text
words = common_english_words()
num_in_subject = random.randrange(3, 9)
subject = ' '.join(random.choice(words) for i in range(num_in_subject))
text = random_english_text()
job = ThreadedJob('email', description, gui_sendmail, (attachment, aname, to,
subject, text), {}, callback)
job_manager.run_threaded_job(job)

View File

@ -23,6 +23,17 @@ def common_english_words():
return ans
def random_english_text():
import random
num_sentences = random.randrange(1, 4)
words = common_english_words()
def sentence():
num_words = random.randrange(23, 42)
return ' '.join(random.choice(words) for i in range(num_words)).capitalize() + '.'
return ' '.join(sentence() for i in range(num_sentences))
def common_user_agents():
return user_agent_data()['common_user_agents']