SendMail Problems with Joomla

We had a very interesting job today. A new client came to us, and told us that his Joomla website was not sending emails. We first thought that it was the settings that he had on his configuration, but everything was fine. His mail settings were correct, he was using “PHP Mailer” as Mailer and his sendmail path was set to /usr/sbin/sendmail. Odd!

We then thought that he didn’t have sendmail installed so we checked on his server and it was indeed, installed. Sendmail did exist under /usr/sbin.

Our next step was to see if it’s a Joomla problem or not, so we created a small test script called test.php on the root directory of the website. The file contained the following code:

$to    = 'ouremail';
$subject= 'Email Subject';
$body    = 'This is the body of the email';
$headers='From: ouremail' . "\r\n" .
'Reply-To: ouremail' . "\r\n" .
'X-Mailer: itoctopus!';
$mail_sent = mail($to, $subject, $body, $headers);
if ($mail_sent)
	echo('Email sent');
	echo('Email not sent');

The example above is just a simple script to send an email to ourselves. The script just prints Email sent in case the email was successfully sent, and Email not sent in case the email wasn’t successfully sent. To our surprise, the script printed Email sent, so the email was actually sent, but how come we received nothing? This case was becoming more curious.

Our next step was to check the mail log, by typing the below (when connected through SSH):

tail /var/log/mail.log

We saw a curious error in the above log that looked like the below:

Feb 14 21:28:36 joomla16 postfix/smtp[19374]: 30F574182B: to=ouremail,[]:25, delay=2.3, delays=0.04/0.01/2.2/0.06, dsn=5.0.0, status=bounced (host[] said: 550 Access denied - Invalid HELO name (See RFC2821 (in reply to MAIL FROM command))

Ah ha! So the mail was indeed sent, but it was rejected by our server. The above error tells us that the cause of rejection is because the server sending the email has a spammy looking hostname (the Invalid HELO name). So, the key to solving the problem lies in the configuration file for Postfix.

Here’s what we did:

  • We opened the file /etc/postfix/ (which is the main configuration file for Postfix).
  • We located this line: myhostname = localhost (this should be the 30th line in the configuration file).
  • We changed it to myhostname =

We restarted postfix and then we tested our email script and it worked! We then moved to test the emails on the Joomla website itself and they worked as well! Problem solved! The whole work, including the investigation and testing, was done in just over 2 hours. Our client was happy, and we were happy!

In case you have problems with mail on your Joomla website, then we’ll be happy to help you (all you need to do is to contact us!). The work shouldn’t take us that much time and it won’t cost you much!

No comments yet.

Leave a comment