Bash Mutt email with attachment error Can't stat : No such file or directory

Rob picture Rob · Feb 10, 2017 · Viewed 7.9k times · Source

So i,ve read some other posts and tried out the answers, but i still keep running into this problem so i wanted to post a question here and see if anyone else had any other ideas. Keeping in mind i am pretty new to bash so i am iffy on whats available currently for what i,m looking for.

I am trying to automate a process that creates a file then sends it to me. All the above is fine, until i try to automatically email myself the file.

I have this line of code for it

echo "report" | mutt -- "$USEREMAIL" -s "report" -a "my_scripts/cid_reports/trb345432.csv"

When it tries to run this command it throws an error like

Can't stat my_scripts/cid_reports/trb345432.csv: No such file or directory my_scripts/cid_reports/trb345432.csv: unable to attach file.

Any ideas on how i can fix this? I thought mutt was good to handle this, I am going to play with the mail feature and see if i can get any success with that.

The system looks to be running

Mutt 1.4.2.2i (2006-07-14)  
Copyright (C) 1996-2002 Michael R. Elkins and others.  
Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -v  

Answer

haitaoli picture haitaoli · Jan 10, 2019
mutt -h

-a <file> [...] -- attach file(s) to the message

The list of files must be terminated with the "--" sequence, so,

echo "hello world" | mutt -s "title" -a /home/test.txt -- ***@**.com

You need to add "--".