flogiston

Blog

Sendmail painfully slow on Ubuntu

· admin · Linux

At the office I'm running ubuntu 8.04 (Hardy Heron).  My machine always took quite some time to boot, mainly due to sendmail trying to do stuff I couldn't care less about.  I just get my morning coffee and by the time I return (the Senseo machine takes equally long to heat, even if the water is already warm :-( ) my machine has booted.   For the few times that I actually need to use sendmail, it takes about a minute to process a mail.  But now I needed to develop and test a new module that would automatically send a mail each time an update/insert was performed.  This made testing very slow, obviously.   So I took some time to google.  A lot of rubbish and very unclear "solutions".  But finally, the gem:

https://www.linuxquestions.org/questions/linux-networking-3/sendmail-problems-after-i-changed-the-name-of-my-linux-box-61719/

Basically, step one is to determine the hostname of your machine:

open up a terminal and type

hostname

This will reveal your hostname.

Let's say it's "vannessa"

Then step two: open up your /etc/hosts file

sudo gedit /etc/hosts

Modify the first line so it reads

127.0.0.1    localhost localhost.localdomain vannessa

(replace "vannessa" with the hostname of your machine, obviously)

That's all it takes.

The next problem I had was that I got no mails at all. So I had a look at the the error logs (found at /var/log/mail.err and /var/log/mail.info). There were lots of messages like this:

May 11 12:09:04 vannessa sm-msp-queue[15550]: n4B7M876008922: to=root, ctladdr=root (0/0), delay=02:46:56, xdelay=00:00:00, mailer=relay, pri=1200805, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
When I tried ssh 127.0.0.1 25 indeed, I got a connection refused
When I tried ssh 10.0.0.107 25 (my IP on the office network), I got a connection.  So basically the smtp server wasn't listening on 127.0.0.1 anymore.

I tried a lot of different things, so I don't know what really did the trick.  Things I tried:

- modify /etc/mail/submit.mc: checked/changed the line
FEATURE(`msp', `[127.0.0.1]', `MSA')dnl
- modify /etc/mail/sendmail.mc: checked/changed the following two lines:

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

checked my /etc/hosts file to comment out
#10.0.0.107    vannessa localhost.localdomain vannessa
and replace it with
127.0.0.1    vannessa localhost.localdomain vannessa
instead

One creates a lot of garbage while trying to fix things. and this garbage may create more problems...

Finally I issued a

sudo sendmailconfig

and answered Y to all questions to rebuild/reload sendmail configuration.

16 comments

antonio ·

LOT (LOT) OF THANKS!!!!

Christopher Johnson ·

This solved my problem where it took forever to post updates on a redmine installation on a home Ubuntu server. Thank you sir!

jim ·

I don't know how to thank you..

Chris ·

YOU ARE THE BOSSMAN. Thanks!

Daniel Del Rio ·

THANK YOU!!! This completely fixed the problem for me.

bobby dennie ·

hey thank dude, was so slow, my setup of sendmail go through sendgrid switf mailer was fast but not sendmail

thank again!

Regards

Nicole ·

Worked great for me as well, and to answer your question about which one it was that worked, I only used the

sudo gedit /etc/hosts

Modify the first line so it reads

127.0.0.1 localhost localhost.localdomain vannessa

and the;

- modify /etc/mail/submit.mc: checked/changed the line
FEATURE(`msp', `[127.0.0.1]', `MSA')dnl

Then ran

sudo sendmailconfig

and answered Y to all questions to rebuild/reload sendmail configuration.

And it worked so that narrows it down a bit..

Nikki

kevin ·

Thanks! Fixed my slow contact form.

Nathan Salter ·

Thank you so much, I was wondering why my sendmail was so slow!

Tyler ·

I love you... Well, I love this post. In other news, I very much don't like php mail().

PS: to those who come afterward... I simply added the hostname to hosts as 127.0.0.1 and then ran sendmailconfig and answered Y to it all. The mail sends, what, 20x faster!!!!!

markfig ·

This worked for me. You blog makes the world a better place! Thanks for posting.

lcmac ·

Thank you so much for posting this. Changing the first lines of my /etc/hosts file from:

127.0.0.1 localhost
127.0.0.1 myserver

to the suggested:

127.0.0.1 localhost localhost.localdomain myserver

did the trick!

Thankfully, I found your page popped up first when I googled the problem.

Best,
lc

William Sidell ·

Thank you so much for posting this!

Peter ·

Thank you very much for sharing this! :)

Daniel @ Hosted Status Page ·

Thanks this solved an issue i was having.

Naura ·

It's works for me, but my mail never arrived on my gmail :(

anyone having same problem?