6

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@xyz.com" -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@xyz.com" < "filename.csv"

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

What am I doing wrong?

user2773648
  • 117
  • 1
  • 2
  • 8
  • Seems like a dupe of http://stackoverflow.com/questions/17359/how-do-i-send-a-file-as-an-email-attachment-using-linux-command-line/4887607#4887607 – chrisinmtown Feb 24 '15 at 19:14
  • 1
    I disagree. I know how to send an attachment. This is simply not working. As opposed to the original post (your link), I do not have mutt, mpack or uuencode available. – user2773648 Feb 24 '15 at 19:20

3 Answers3

5

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@xyz.com"

It worked just fine.

user2773648
  • 117
  • 1
  • 2
  • 8
1
uuencode filename.csv filename.csv | mailx -s "this is my email subject" "email@xyz.com"

Or, if you want to clump text and an attachment together, then

echo "this is my email body" | cat -<(echo uuencode filename.csv filename.csv) | mailx -s "this is my email subject" "email@xyz.com"
access_granted
  • 1,807
  • 20
  • 25
0

I came across the same problem, use -A instead of -a. It worked for me.

  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/31588747) – Ethan Apr 27 '22 at 20:30