I have in the past heard of using nail for this task, but I can't seem to find it for my distribution (Ubuntu 11.04) in any of the repositories. What program can I use to one-off emails from a shell like so:

send-mail -to me@email.com -file attachment.zip -message "Hello World"

Is there a program out there through which I can script mail sending as above?


nail was renamed to Heirloom mailx. For Ubuntu, you want to install the heirloom-mailx package, and then read the Sending mail from scripts section of the manpage.

  • Where is the mail.rc file stored? I'd like to store my account info in there. – Naftuli Kay May 31 '11 at 1:11
  • @TK, do you mean /etc/nail.rc (note the n) or ~/.mailrc? See the env vars & files sections of the mailx manpage. – cjm May 31 '11 at 1:30
  • ~/.mailrc. Thanks, I've got it all configured now! :) – Naftuli Kay May 31 '11 at 2:03

You can use ls -ltr | mail -s "Files in sys" yourmail@domain.com

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.