On 14Oct2015 14:44, mathieu.c...@free.fr <mathieu.c...@free.fr> wrote:
In fact, my problem comes from a strange way of linux startup [...]
I figured out that the daemon which is launched at boot as service (stored in
/etc/rc2.d)
is executed as root but with a HOME=/ environment variable...
It seems that mutt tries to write content of mail in a sent file which is
located in this HOME folder
and it seems too it can't write in the / folder. When I restart my daemon, the
HOME env var is well
defined as /root folder and emails are sent correctly.
Personally, I tend to invoke sendmail directly and reply on the system's mail
system. Assuming it is correctly set up, but that is worth doing anyway.
However, if you want "sent" copies etc then mutt is a convenient tool to make
them.
I tried to set/export the HOME var at beginning of the daemon code but it still
has the / value
That should work. Can you show us the code you used which did not worK?
I then stored a .muttrc in / folder which is defining :
set record = '/root/sent'
and since, all is Ok but it is a solution I do not appreciate because I have
to store the .muttrc file in
/, /root, ...
Yes, that is not pretty.
You can invoke mutt with -e options to issue commands, for example:
mutt -e 'set record = "/root/sent"' ...
You can also tell it where the muttrc file is:
mutt -F /root/.muttrc ...
However, it might be best to set $HOME in your daemon startup script.
NB: replies to mutt-dev please, not to me personally.
Cheers,
Cameron Simpson <c...@zip.com.au>
Mathieu
----- Mail original -----
De: "Cameron Simpson" <c...@zip.com.au>
À: "mathieu cier" <mathieu.c...@free.fr>
Envoyé: Mercredi 14 Octobre 2015 13:17:57
Objet: Re: mutt returns a 256 error code
On 14Oct2015 10:52, mathieu.c...@free.fr <mathieu.c...@free.fr> wrote:
Hi Cameron,
Thanks for tip.
I'll test it but quoting are ok since mutt can sometimes send mails
Maybe the quoting isn't ok if it is only sometimes.
By bypassing the shell (and thus quoting) entirely you get to avoid all sorts
of issues that may come from eg quote characters in the message body or
subject.
If you're concerned, you could put some tracing in your shell command, eg:
set -x; echo "body of the mail" | mutt -s "mail's subject" some...@domain.com
assuming the output goes somewhere where it can be watched.
Cheers,
Cameron Simpson <c...@zip.com.au>
Mathieu
----- Mail original -----
De: "Cameron Simpson" <c...@zip.com.au>
À: "mathieu cier" <mathieu.c...@free.fr>
Cc: mutt-dev@mutt.org
Envoyé: Mercredi 14 Octobre 2015 00:17:41
Objet: Re: Fwd: mutt returns a 256 error code
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>