0

How can I send a file as an attachment via email in bash script, without using mutt and uuencode?

3
  • 4
    It's kind of weird to tag this mutt when you specifically don't want that....
    – mattdm
    Jun 2, 2016 at 15:51
  • sorry, newbie to this kind of forum.
    – user548682
    Jun 2, 2016 at 16:25
  • On what operating system (if Linux, what distribution)? The available commands for sending mail differ quite a lot on different unix variants. Jun 3, 2016 at 21:44

1 Answer 1

2
echo "Message body" | mailx -s "Subject" -a "/path/to/attachment" [email protected]

or

cat "/path/to/messagebody.txt" | mailx -s "Subject" -a "/path/to/attachment" [email protected]
9
  • Thanks for the answer. But I didnt get it work to send as attachment.
    – user548682
    Jun 2, 2016 at 16:30
  • Could you be a bit more specific than 'it didn't work'?
    – DopeGhoti
    Jun 2, 2016 at 17:19
  • mail: invalid option -- a Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ... [-- sendmail-options ...] mail [-iInNv] -f [name] mail [-iInNv] [-u user]
    – user548682
    Jun 2, 2016 at 17:22
  • I got this error.
    – user548682
    Jun 2, 2016 at 17:22
  • 1
    @DopeGhoti - things that are not the same mailx. There are several different versions of mail/mailx, all with different options and capabilities. On Debian, for example, there are (at least) bsd-mailx, heirloom-mailx, and s-nail packages which provide different versions of mail and mailx.
    – cas
    Jun 3, 2016 at 2:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .