If you want to use Sendmail, install it, dummy!

Right…I must have forgotten to install sendmail, because mail wasn't working for WordPress. First, to verify that sendmail wasn't working I ran this PHP script (thanks to phpeasystep.com)

// send e-mail to ...

// Your subject

// From
$header="from: your name <your email>";

// Your message
$message="Hello rn";
$message.="This is testrn";
$message.="Test again ";

// send email
$sentmail = mail($to,$subject,$message,$header);

// if your email succesfully sent
echo "Email Has Been Sent .";
else {
echo "Cannot Send Email ";


That confirmed it. And the fix was easy:

apt-get install sendmail

Doing this exposed a flaw in my hosts file and ZYXware.com had the answer

sudo gedit /etc/hosts localhost.localdomain localhost zyxware01.localdomain zyxware01

If you have a static IP you can replace with your static IP.

So, now mail works from php and, more importantly, WordPress.

Sheesh…Ubuntu is picky. Here's (almost) exactly what I have for the top half of my hosts file    myhostname    localhost.localdomain    localhost
::1    myhostname    localhost6.localdomain6    localhost6    myhostname    myhostname.mydomain.com

The spaces are actually tabs, I don't know if it matters.

I also don't know what is needed and what is not, but I mimicked this layout on a new server and it worked; the MTA blah-blah service no longer takes forever and sendmail works nice and quickly.

Leave a Reply

Your email address will not be published.