Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mailx: "send-mail: illegal option -- a" while attempting to send file attachment

Tags:

mailx

Our production server has been retired and now we are using a hosted system running Redhat GNU/Linux.

We had many scripts using mutt to send file attachments but they're failing now since mutt is not installed on our servers (The sysadmin policy is that mutt is not secure so it will not be installed)

I have tried using mailx but to no avail. When I do

echo "this is my email body"| mailx -s "this is my email subject" "[email protected]" -a "filename.csv"

I get

$ send-mail: illegal option -- a

"filename.csv" exist and it is local to the directory I run the command from. Of course, when I do

mailx -s "this is my email subject" "[email protected]" < "filename.csv"

It works but it embeds the file attachment in the email body. Users do not want that.

What am I doing wrong?

like image 636
user2773648 Avatar asked Feb 24 '15 19:02

user2773648


1 Answers

I figured it out. I simply moved the -a flag before the email address like so

echo "this is my email body"| mailx -s "this is my email subject" -a "filename.csv" "[email protected]"

It worked just fine.

like image 121
user2773648 Avatar answered Sep 24 '22 14:09

user2773648