Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

[Mutt | CentOS 5.1] I have set up Mutt on CentOS and configured /etc/Muttrc and ~/.muttrc files. I can send email out without attachments, command:

echo $Message | mutt -s "WARNING $Subject"

and this works well for corporate's email address, e.g.

echo $Message | mutt -s "WARNING $Subject" sample@corp.domain

When sending email with attachments, weird results come out. I will explain in cases as below.

1> When send to personal email address (, multiple files can be attached.

echo $Message | mutt -s "NORMAL $Subject" \
     -a test1.log -a test2.log

2> When send to corporate email address (sample@corp.domain), emails cannot be sent out if files attached. (cmd similar as above). But the interesting thing is, if I attach the /root/install.log FIRST, the email can be sent out with attachments, cmd as below:

echo $Message | mutt -s "NORMAL $Subject" sample@corp.domain \
      -a /root/install.log -a test1.log -a test2.log

Case would fail to send if attachment order changed.

I cannot figure out where the problem exists from above cases, any configuration I may miss?

share|improve this question

Since you are piping stuff into mutt, you must use the -x (mailx compose mode) option first.

share|improve this answer
Can you provide a full command for reference? BTW, this doesn't explain why case 1 succeeds to send email, while case 2 not. – Andrew Mar 16 '12 at 14:24
echo $Message | mutt -x -s "WARNING $Subject" You do that because mutt is a console (curses) application and you're piping something to its stdin, so it has to read from stdin. – adamo Mar 16 '12 at 16:05

From mutt(1):

   -a file [...]
          Attach  a  file  to  your  message  using MIME.  When attaching single or  multiple files, separating filenames and
          recipient addresses with "--" is mandatory, e.g. mutt -a image.jpg -- addr1 or mutt  -a  img.jpg  *.png  --  addr1
          addr2.  The -a option must be placed at the end of command line options.
share|improve this answer
Do you mind provide more details and explain the different results between case 1 and 2? – Andrew Mar 16 '12 at 14:25
The man page says that you should specify -a only once. Anyway, I just tried commands like: echo test | mutt -s "prova" -a /tmp/wut.png -a /etc/motd. They work, also with gmail accounts. – ema Mar 16 '12 at 16:47

I ran into this same problem today. You don't say what the error msg is, but I bet it said "can't stat unable to attach file".

This is the solution. "--" is mandatory, e.g. mutt -a image.jpg -- Note: The -a option must be placed at the end of command line options. /ubuntu/+source/mutt/+bug/805613

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.