Jump to content
Froxlor Forum
  • 0

php mail() function OK, PHPMailer not OK


sporkman

Question

I'm stumped by this. Code like this works both from the command line (php -f mailtest.php) and via the web. No errors, mail is seen hitting my local ssmtp instance (this host is not running the mail server portion of froxlor):

<?php 
    ini_set( 'display_errors', 1 );
    error_reporting( E_ALL );
    $from = "emailtest@YOURDOMAIN";
    $to = "YOUREMAILADDRESS";
    $subject = "PHP Mail Test script";
    $message = "This is a test to check the PHP Mail functionality";
    $headers = "From:" . $from;
    mail($to,$subject,$message, $headers);
    echo "Test email sent";
?>

WordPress, which uses PHPMailer fails to send mail silently. No errors in php-fpm's log, no errors in apache, and if I turn on php errors and WP_DEBUG, nothing, just silent failure.

Also noticed that when I add new customers in froxlor, there is an error about not being able to send email.  AND froxlor uses PHPMailer.

So what might be stopping PHPMailer from working system-wide, but not php's mail() function?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

This is some weird php/phpmailer/pcre2 issue apparently.

For Froxlor, just updating phpmailer to a current version will resolve it (I tested with 6.0.7).  For Wordpress, same thing, have to wait for them to sync up with the current version of phpmailer.

Other workarounds:

- downgrade to php 7.2

- manually build php 7.3 from source using a few specific versions of pcre that don't expose the bug

- in Wordpress, add a filter to disable the regex: add_filter( 'wp_mail_from', function($from){PHPMailer::$validator = 'noregex'; return $from;} )

Just answering here for anyone wandering in from google...  It's vexing because unless you turn on debugging in phpmailer, you get a very generic 'invalid address' error (sender? recipient? who knows?).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...