On 13Oct2015 20:28, mathieu.c...@free.fr <mathieu.c...@free.fr> wrote:
I am currently using mutt 1.5.18 within a python script for reporting some
activities about an embedded linux system.
I do not get any problem when launching the mutt command within a terminal but
I get troubles when launching from my python script.
The command I use is pretty simple :
echo "body of the mail" | mutt -s "mail's subject" some...@domain.com
That command is called in the python script by:
retvalue = os.system(command)
BTW, you might consider using subprocess:
from subprocess import Popen, PIPE
P = Popen(['mutt', '-s', mail_subject, target_address], stdin=PIPE)
P.stdin.write(message_body)
P.stdin.close()
xit = P.wait()
This avoids all sorts of nasty shell quoting issues that are inherent in your
os.system() invocation.
Cheers,
Cameron Simpson <c...@zip.com.au>