[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" sample@gmail.com

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 (sample@gmail.com), multiple files can be attached.

echo $Message | mutt -s "NORMAL $Subject" sample@gmail.com \
     -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?


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

  • 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" sample@gmail.com 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.
  • 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" emanuele@example.com -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.

http://ubuntuforums.org/showthread.php?t=1586810 http://www.linuxquestions.org/questions/linux-software-2/mutt-someone@somedomain-com-unable-to-attach-file-844315/

bugs.launchpad.net /ubuntu/+source/mutt/+bug/805613

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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