2

I'm trying to send a csv file as an attachment through the command line in Ubuntu. Currently, when running what seems to be the right command an e-mail is sent however, the contents of the CSV file are sent in the body instead of an actual file.

Any ideas? The command used is:

mailx -a ./filename email@address.co.uk
terdon
  • 104,119
fiverivers
  • 23
  • 1
  • 4

2 Answers2

1

You can use the command mutt for this purpose

mutt -s "Test mail" -a /tmp/file.tar.gz -- you@domain.com < /tmp/mailmessage.txt

Where /tmp/file.tar.gz is the attachment and /tmp/mailmessage.txt is the content of mail

aneeshep
  • 30,949
1

the code I used

mail --subject="what ever" --attach=foo.csv me@me.com <<foobarbaz

mail with file

foobarbaz

with

  • --attach specifying the file to be send
  • <<foobarbaz is syntax for an here document (i.e. will send to mail all data up to a line begining with foobarbaz )

Edit:

from man mailx

  • -a, --append=HEADER: VALUE append given header to the message being sent
  • -A, --attach=FILE, attach FILE
Archemar
  • 682