Frage

running a Joomla 2.5.8 website all server-generated emails are marked as spam (only by gmail though!).

I ran the tests on the great resource http://www.mail-tester.com and the only negative score I'm getting is (spamassassin test):

-1.105      MIME_HTML_ONLY      Message only has text/html MIME parts
You should also include a text version of your message (text/plain)

I dug into the code and found that libraries/joomla/mail/mail.php does not set an AltBody for Text equivalent; I tried:

public function setBody($content)
{
    [...]
    if (empty($this->AltBody))
        $this->AltBody =JMailHelper::cleanText( strip_tags( $content));

and it works! (10/10 on mail-tester). But it sure is ugly.

My questions are:

  • should we consider this a Joomla! bug and file it?
  • is there a cleaner solution without hacking into core files, maybe some configuration?

Else I'll write a plugin to perform the override: this is quite important as we're losing 20% of customers who cannot seem to find the spam folder in gmail!!!, and I don't really feel like core-hacking 30 sites.

War es hilfreich?

Lösung

Definitely a bug that can be filed with the CMS. The system should handle it for you. Here's how to get started on filing bugs: https://github.com/joomla/joomla-cms/blob/master/CONTRIBUTING.md

Also, rather than hacking core files as you said, you can write up a plugin to handle his override for you. I've put together a base plugin that allows you to override core classes as needed here: https://gist.github.com/dongilbert/3237387

As you can see, nothing too complicated going on there. We first make sure we are in Joomla, otherwise exit. Then define the class following Joomla naming convention, and include our config file in the class construct. The config file is where the classes get registered to the autoloader.

In the config file, we define the OVERRIDES path, and then start registering classes to JLoader. I like to keep things organized, so my overrides directory mirrors the structure of the root joomla directory, only containing paths to classes that I want to override. Meaning if I want to override JFormField, I would have a structure like this (including the overrides directory):

overrides/libraries/joomla/form/field.php

And then in config.php I would add:

JLoader::register('JFormField', OVERRIDES.'/libraries/joomla/form/field.php', true);

You can also use this to override core component classes. I used it to override a view class in com_media like this:

overrides/component/com_media/view/imageslist/view.html.php

and then of course adding this to the config:

JLoader::register('MediaViewImagesList', OVERRIDES.'/components/com_media/view/imageslist/view.html.php', true);

You can download the plugin from the gist link above. It is ready to install into your Joomla site. Upload it first, and then add the overrides directory in the plugin directory. If you want to add all the files first and the upload, be sure to add the following to the overrides.xml file.

<folder>overrides</folder>

Andere Tipps

Thanks for this! I noticed the same problem in Joomla 3.

Anyway I solved it with a simple

$mailer = JFactory::getMailer();
(...)
$mailer->setBody($messagebody);
$mailer->AltBody =JMailHelper::cleanText( strip_tags( $messagebody));

No need to edit the source, nor I think this should be reported as bug (one should be able to set the AltBody as it fits better) - but it would be nice to have it properly documented, or maybe have a setAltBody() method.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top