Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 just trying to send myself an e-mail. On on Ubuntu using sendmail. For some reason, it doesn't work. Here's the command I'm running and what shows up when I run it:

jason@ve:~$ echo "Subject: test" | /usr/lib/sendmail -v Connecting to [] via relay...
220 ESMTP Sendmail 8.14.3/8.14.3/Debian-9.1ubuntu1; Wed, 29 Dec 2010 13:51:49 -0800; (No UCE/UBE) logging access from: localhost.localdomain(OK)-localhost.localdomain []
>>> EHLO Hello localhost.localdomain [], pleased to meet you
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<> SIZE=14
250 2.1.0 <>... Sender ok
>>> RCPT To:<>
>>> DATA
250 2.1.5 <>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
050 <>... Connecting to via esmtp...
050 <>... Deferred: Connection refused by
250 2.0.0 oBTLpnEj012261 Message accepted for delivery Sent (oBTLpnEj012261 Message accepted for delivery)
Closing connection to []
>>> QUIT
221 2.0.0 closing connection

It seems to me that the "Connection refused by" part is where things are going wrong, but I have no idea where or how to begin troubleshooting. Any advice?

$ grep /etc/mail/
O DaemonPortOptions=Family=inet,  Name=MTA-v4, Port=smtp, Addr=
O DaemonPortOptions=Family=inet,  Name=MSP-v4, Port=submission, M=Ea, Addr=
R<@> < $* @ [] >
                        $: < ? $&{client_name} > < $1 @ [] >
R127.0.0.1              $@ RELAY                originated locally
# DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=')dnl
# DAEMON_OPTIONS(`Family=inet,  Name=MSP-v4, Port=submission, M=Ea, Addr=')dnl
share|improve this question
Is your mail server hosted on the same machine? If so, it should be a local delivery and not extending to the 205.x.x.x address. – ewwhite Dec 29 '10 at 22:08

Looks like you don't have port 25 open in your firewall rules. Here is what I see open

22/tcp   open     ssh
80/tcp   open     http
3306/tcp open     mysql

Looks like the default sendmail config on Ubuntu is to just listen on localhost. Edit the following line in your /etc/mail/

DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=')dnl


DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=')dnl

and run make in /etc/mail and then run /etc/init.d/sendmail reload. Once this is done you can confirm that sendmail is listening on all addresses using

netstat -tnlp

As a note, in modern distributions, you should not be editing your file by hand. That way lies madness.

share|improve this answer

I just wrote a complete lengthy response based on my failure to realise that the host you're doing this from,, is also, the primary MX for

For what it's worth, if what you're really complaining about is your mail server's inability to receive mail, couching this in a question about your inability to send email probably isn't the best way to get a result.

It is likely that your issue is that your mailserver isn't listening on port 25, at least not on the external interface. Could you do a grep /etc/mail/ and let us know the results?

Edit: since you've done that, it's now clear that your sendmail is configured to listen only on, and you need to fix that. slillibri is right, you don't want to edit by hand if you can avoid it, which means going into /etc/mail and editing the relevant line out of I can't speak for ubuntu, but on Fedora/CentOS, this usually means changing the line

DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')dnl


dnl DAEMON_OPTIONS(`Port=smtp,Addr=, Name=MTA')

please note that putting a # at the beginning of the line does NOT comment out a line in an m4 file such as this; you must prepend dnl to comment the line out. Then regenerate the file with make and restart with service sendmail restart. The procedure on ubuntu is likely to be similar.

Once this is done, do a netstat -apn|grep -w 25 and look for something like

tcp        0      0      *                   LISTEN      2012/sendmail: acce 

The important bit is, which means sendmail is listening on all interfaces; if it still says you've still got the problem.

share|improve this answer
I've updated my original post with that output. How do I make my mailserver listen on port 25? – Jason Swett Dec 30 '10 at 19:21
See my edits above. – MadHatter Jan 5 '11 at 6:00

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.