On my server, sendmail was taking 60s to send a simple message. After some googling, I found out that it was due to a DNS problem. I had this log:
Sep 13 08:00:01 myserver sm-msp-queue[1493]: My unqualified host name (myserver) unknown; sleeping for retry
Sep 13 08:01:01 myserver sm-msp-queue[1493]: unable to qualify my own domain name (myserver) -- using short name
The solution was to edit /etc/hosts and add names with a dot at the end
127.0.0.1 localhost locahost.
127.0.0.1 myserver myserver.
Now sendmail runs very quickly, but the messages as not delivered anymore. I'm sending just a "hello" to my gmail account.
echo "hello" | sendmail -v "xxx@gmail.com"
I've seen some people saying that the remote server may reject messages, but I don't understand, because they were being delivered before altering the hosts file. I don't want to host a mail server. I just need to send messages to myself. Here's the output from the command line above:
220 myserver. ESMTP Sendmail 8.14.4/8.14.4/Debian-4.1ubuntu1; Fri, 18 Sep 2015 13:50:45 -0300; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
>>> EHLO myserver.
250-myserver. Hello localhost [127.0.0.1], pleased to meet you
...
250 2.0.0 Verbose mode
>>> MAIL From:<www-data@myserver> SIZE=3 AUTH=www-data@myserver
250 2.1.0 <www-data@myserver>... Sender ok
>>> RCPT To:<xxx@gmail.com>
>>> DATA
553 5.1.8 <xxx@gmail.com>... Domain of sender address www-data@myserver does not exist
503 5.0.0 Need RCPT (recipient)
>>> RSET
250 2.0.0 Reset state
>>> RSET
250 2.0.0 Reset state
www-data@myserver... Using cached ESMTP connection to [127.0.0.1] via relay...
>>> MAIL From:<> SIZE=1027
250 2.1.0 <>... Sender ok
>>> RCPT To:<www-data@myserver>
>>> DATA
250 2.1.5 <www-data@myserver>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
050 <www-data@myserver>... Connecting to local...
050 <www-data@myserver>... Sent
250 2.0.0 t8IGojKw022539 Message accepted for delivery
www-data@myserver... Sent (t8IGojKw022539 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 myserver. closing connection
Messages are delivered when I specify a real sender address:
echo "hello" | sendmail -vf "sender@realdomain.com" "xxx@gmail.com"
But why messages were delivered when it couldn't resolve it's own name, and not now?
sendmail -d0.1 </dev/null
) with/etc/hosts
reverted to the previous contents. Remote mail servers will rightly reject anything from the unqualified name ofmyserver.
; this must be qualified tomyserver.example.com
or such. – thrig Sep 18 '15 at 17:20exim4
but I have forgotten everything I once knew about sendmail configuration, sorry. Note that if you are only sending to gmail addresses you don't even need to authenticate for theaspmx.l.google.com
delivery host. – Chris Davies Sep 18 '15 at 17:23