• Home
  • Blog
  • Joomla 'com_contact' and the fix

Joomla 'com_contact' spammy emails fix

Spam, we all hate it - especially when our contact form is meant to block the spammy fake contacts. Recently a number of our websites were hit with a huge amount of spam, even when we had entered some 'keywords' into the 'banned text' field within the Joomla 'com_contact' component. The spam emails just kept coming and coming. It was then that we decided something was wrong and went looking at what was wrong and how to fix it.

After doing a bit of research we found that a bug report had been submitted back in Aprilby Klaus Baldermann, posting the issue and a fix to the contact component within Joomla 2.5 (and now Joomla 3.0). It then took 6 months before a patch was submitted by Elin Waring which contained the updated and working PHP files. From what we can gather the patch was accepted sometime before the 10th of November which applied to Joomla 3.0 only. That's all good and well until we downloaded fresh copies of both Joomla 2.5 and Joomla 3.0 to find that the patch had been reverted prior to Joomla 2.5.8 and Joomla 3.0.2. Within the bug tracker there is no mention as to why the patch had been reverted.

Below we will tell you what files and the lines of code that you will need to edit in order to fix the 'com_contact' component - at least until the Joomla developers release a patch and keep it within Joomla.

There are three files that need to be edited to fix the contact form component which are as follows:

  1. contactemail.php
  2. contactemailmessage.php
  3. contactemailsubject.php

'com_contact' - the broken code

foreach(explode(';', $banned) as $item) {
if (JString::stristr($item, $value) !== false) {
return false;

'com_contact' - the working code

foreach(explode(';', $banned) as $item) {
if ($item != '') {
if (JString::stristr($value, $item) !== false) {
return false;

Below you will find the line numbers that represent each file that you will need to edit. The line numbers may be different and should only be used as a reference ONLY.

  1. contactemail.php - lines 44 to 50
  2. contactemailmessage.php - lines 38 to 44
  3. contactemailsubject.php - lines 38 to 44

If you would like us to fix your 'com_contact' for you, let us know by using our working contact form below.