How to fix slow sendmail on a Digital Ocean Ubuntu droplet

I recently switched over to Digital Ocean for my main server thanks to Bryan Poetz‘s  suggestion, and was running into an issue where mail was sending but slowly. Turns out there were two problems.

First, I had named the droplet “main” (since it was, you know, the main server), but this really should be a Fully Qualified Domain Name (FQDN) instead. So I renamed the droplet to main.bhconsulting.ca and restarted sendmail. However looking at the mail logs I saw lots of:

unable to qualify my own domain name (main) — using short name

Since it was still using “main” as the server name. Thanks to help from this thread I modified the /etc/hosts file from:

127.0.0.1 localhost
127.0.1.1 main main

to:

127.0.0.1 localhost.localdomain localhost main.bhconsulting.ca
127.0.1.1 main.bhconsulting.ca main

voila, fast sendmail.