Is it possible to email attachments from the command line?
If possible, I'd like something as simple as:
mail -a myfile.txt -t email@example.com -s "Here's my file"
Of all the mail user agents in the Ubuntu repository, it appears that mutt is the command-line MUA that is blessed with Long Term Support.
According to the manual, you can do something exactly like:
except it won't go anywhere since one also needs a Mail Transfer Agent. Popular ones are:
and the only ones that Canonical seems to support are postfix (thanks for the correction Steve) and exim4.
One could also say that xdg-email is also a proper Ubuntu MUA, but it is a bare-bones front end which only executes your preferred MUA on your behalf.
If you'd like advice on which MTA might be suitable for your use, perhaps open another question here.
I had bad trouble with sending attachment files, too. When I sent an email without attachment, it was successful but was not with attachment. This problem was existent with
Fortunately, It was solved funnily. I use Gmail for sending email. You can configure your gmail for sending emails via commands in terminal as declared at http://www.linuxandlife.com/2013/01/send-email-from-linux-terminal.html .
You can send a text email using:
but you can't send same file as attachment as below:
Finally, I understood that only this format could send an attachment:
Funnily, the difference is existence of the "echo" command.