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'm trying to send mail from shell(GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)) using;

mail foo@bar.com

After I complete the command, the mail won't show up in the mailbox. What could be wrong, how can I check is my configuration is correct. Thanks.

share|improve this question
Your local MTA (Mail Transfer Agent) needs to be configured to send mail to external mail addresses. You can try running mail w/o params to see if the message was returned to you by the local mailserver with the diagnostics message. – alex Mar 2 '11 at 9:26
up vote 1 down vote accepted

Like every unix program that occasionally has cause to send email notifications, mail assumes that there is a functioning MTA on localhost that is 1) capable of accepting mail and 2) knows how to pass it on.

To find out what mail server you're running, try telnet localhost 25 and look at the identifier string.

The command mailq, if it exists for you, will show you what messages are currently in the local mail server's queue, possibly with an explanation as to why it hasn't been passed on to its destination yet.

In addition, most distributions by default configure MTAs and syslog to report mail log messages to either /var/log/mail.log or similar. Look in /var/log/ for any file that looks viable, and grep it for 'bar.com'

Without more information as to what's going on it's hard to offer better advice than this, sorry.

share|improve this answer

Use a "mail" command that has an option to show you the SMTP dialog. The "heirloom" project has a good version of such a command: http://heirloom.sourceforge.net/mailx.html

Here's an example "mailx" (apparently a 4-year-old v12.1) command invocation, showing the SMTP dialog:

10:50AM 2 % mailx -v -s "test email" bediger
test letter text
bediger... Connecting to [] via relay...
220 mydomain.com ESMTP Sendmail 8.13.8/8.13.3; Wed, 2 Mar 2011 10:50:37 -0700
>>> EHLO myhost.intranet
250-mydomain.com Hello localhost [], pleased to meet you
250 HELP
>>> MAIL From:<bediger@myhost.intranet> SIZE=222 AUTH=bediger@myhost.intranet
250 2.1.0 <bediger@myhost.intranet>... Sender ok
>>> RCPT To:<bediger@myhost.intranet>
>>> DATA
250 2.1.5 <bediger@myhost.intranet>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 p22HobSb015513 Message accepted for delivery
bediger... Sent (p22HobSb015513 Message accepted for delivery)
Closing connection to []
>>> QUIT
221 2.0.0 mydomain.com closing connection
10:50AM 3 %

That sort of information can be invaluable in figuring out what goes wrong with email delivery.

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.