Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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.

share|improve this answer
Where is the mail.rc file stored? I'd like to store my account info in there. – Naftuli Tzvi 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 Tzvi Kay May 31 '11 at 2:03

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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