1

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.

notdodo
  • 149
  • 2
  • 15
  • Are you getting an error? Could you try an even larger body with `echo`, in case the difference in size between "thunderbird -compose" and "echo" crosses some boundary? – Patrick Haugh Jan 06 '17 at 20:15
  • 2
    Try running the call from your command-line. This could be a `thunderbird` limitation, or maybe you're hitting the limit with the character difference between `thunderbird -compose` and `echo` – salezica Jan 06 '17 at 20:16
  • @slezica nice hint (I'm dumb), I've edited the question – notdodo Jan 06 '17 at 20:24
  • 1
    Not the solution, but running `getconf ARG_MAX` you can obtain the maximum length for shell arguments. If `echo` can take it, this could just be a `thunderbird` limitation – salezica Jan 06 '17 at 20:28
  • @slezica: yes, I think too, now, that the problem is thunderbird. The `ARG_MAX` size is 2097152. – notdodo Jan 06 '17 at 20:35
  • You may want to consider just using the [email library](https://docs.python.org/2/library/email-examples.html) in Python directly to avoid these kinds of limitations. – merlin2011 Jan 06 '17 at 20:43

1 Answers1

-1

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.

notdodo
  • 149
  • 2
  • 15