python - subprocess length limit

1.3k views Asked by At

I have to create an email from a python script calling:

subprocess.call([
    'thunderbird',
    '-compose',
    "preselectid='{}',to='{}',cc='{}',subject='{}',body='{}'".format(
        preselectid, to, cc, subject, body),
    ])

but the email is truncate when the body is "too" large.

I know that on Windows there is a limit of 32,768 char (What is the subprocess.Popen max length of the args parameter?) but I'm on Linux (using zsh) and when echoing the string with

subprocess.call([
    'echo',
    "preselectid='{}',to='{}',cc='{}',subject='{}',body='{}'".format(
        preselectid, to, cc, subject, body),
    ])

I get the complete and correct email content.

How can I solve this problem?

EDIT: Thanks to @slezica I've found out that copy-pasting the generated email and running the command from command-line I get, anyway, the truncated email (at the 32,303 char). The problem is thunderbird.

1

There are 1 answers

0
notdodo On BEST ANSWER

This is quasi-answer.

After opening a bug report (https://bugzilla.mozilla.org/show_bug.cgi?id=1329312) I was informed that Thunderbird's developers

implemented an option where you can read the message from a file with message=, see bug 882104. That will be shipping in TB 52, so you could use this now in Earlybird.