“Email could not be sent.” Error When Emailing Articles on a Joomla Website

Using caching in Joomla will come back to haunt you. (Source: the team at itoctopus!)

If you are using caching on your website, and we’re not even talking about page level caching, just global caching, you might have experienced some broken functionality here and there. Even if you haven’t noticed anything wrong on your website, chances are, there is something wrong but you don’t know where it is. Even in 2014, caching in Joomla is still unreliable and can cause stability issues.

One of the common problems that are related to caching is the inability to email the link of an article to a friend: when someone tries to use this functionality, he gets the following error after filling in the form and pressing on submit:

Email could not be sent.

There are two ways to solve the problem:

  1. Disable global caching: You can disable global caching by logging in to the backend of your Joomla website, and then going to Site -> Global Configuration and then clicking on System, and then on the right side, under Cache Settings, choosing OFF – caching disabled next to Cache, and finally clicking on the Save button on the top right. This will fix the problem, however, this fix will also make your website slower (much slower if you have a large website). We usually opt for this solution when the website is quite small (and will remain small) and caching is not really needed.
  2. Disable content caching: For some reason, enabling global cache, also enables some sort of content caching, which is not the right behavior, since content caching is controlled by the System – cache plugin. In any case, to disable content caching, you should do the following:

    • Open the file controller.php, which is located in the component/com_content folder .
    • Remove the following line from the beginning of the display function:

      $cachable = true;

    • Save the file and upload it back to your Joomla website.

    This solution will fix the problem, and will not have a drastic effect on the performance of your website.

But, why is the problem related to caching?

We’re glad you asked! You see, when you load an article, Joomla runs a script to generate a hash for that article, and then associates that hash with the URL of the article. The link for “emailing the article to a friend” will contain that hash, and so, when you fill in the popup form and click on Submit, Joomla will check that hash, and will get the article’s URL based on the hash, and then will email the link of the article to your friend. Joomla does this whole hash thing to prevent spammers from using your website as a mean to spam other people.

Now, this is all fine, but the problem is that the association between the hash and the article’s URL is stored in the session. When the content is cached, then all the session activities that are related to this task are skipped (including the storage of the URL and the hash in the session), which means that Joomla will no longer know which article’s URL corresponds to the hash, and thus, will prevent the email from being sent.

Now, if you have this problem on your website, then try first to disable caching and see if it solves the problem, if it does, and if you really need caching, then re-enable caching and implement the second method above. If you need help in the implementation, then just contact us and we’ll do it for you in no time and for a very affordable fee!

No comments yet.

Leave a comment