Trouble with email sending in ModX Revolution via FormIt

1.9k Views Asked by At

There is a trouble with email sending in Modx Revolution. Using FormIt plugin, I tried to enable Gmail SMTP at Modx settings list, but the same result. Now SMTP is disabled.

Using this FormIt call:

[[!FormIt? 
     &hooks=`email,redirect`
     &redirectTo=`19`
     &redirectParams=`{"success":"1"}`
     &emailTpl=`feedbackEmailTpl`
     &emailSubject=`New request from [[++site_name]]`
     &emailTo=`***@gmail.com`
     &emailToName=`Support`
     &emailReplyTo=`***@gmail.com`
     &emailFrom=`***@gmail.com`
     &emailFromName=`***@gmail.com`
     &errTpl=`<span class="label label-warning">[[+error]]</span>`
     &validate=`
         name:required:stripTags,
         clientemail:email:required,
         message:required:stripTags
     `
     &clearFieldsOnSuccess=`1`
     &validationErrorMessage=`Error.`
]]

In error.log file:

[2015-06-02 10:33:37] (ERROR @ /var/www/site/core/model/modx/mail/phpmailer/class.phpmailer.php : 893) PHP warning: preg_match(): Compilation failed: internal error: previously-checked referenced subpattern not found at offset 728
[2015-06-02 10:33:37] (ERROR @ /var/www/site/core/model/modx/mail/phpmailer/class.phpmailer.php : 893) PHP warning: preg_match(): Compilation failed: internal error: previously-checked referenced subpattern not found at offset 728
[2015-06-02 10:33:37] (ERROR @ /index.php) [FormIt] Произошла ошибка при попытке отправить почту. Пожалуйста, введите хотя бы один адрес e-mail получателя.

What can be wrong? Is this trouble bound to PHPMailer?

1

There are 1 best solutions below

0
On BEST ANSWER

This is a PHP bug that affects PHP 5.5.25 and 5.6.9 when run using mod_php with apache. There are a few workarounds until it's fixed in PHP.

  1. Downgrade PHP to 5.5.24 or 5.6.8
  2. Switch to PHP-FPM instead of mod_php (which is a good idea anyway)
  3. Override the PHPMailer class and change the default email validation method to 'php'.

This last method would be done like this:

class myMailer extends PHPMailer
{
    public static function validateAddress($address, $patternselect = 'php')
    {
        return parent::validateAddress($address, $patternselect);
    }
}

Then use that subclass instead of the plain PHPMailer class. The same bug has been affecting various other PHP projects such as Typo3 and SwiftMailer. The bug to track it in PHPMailer is here.