5

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.

  • 1
    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
1

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.

1

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
.
EOT
bediger... Connecting to [127.0.0.1] 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 [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
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 [127.0.0.1]
>>> 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.

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.