Jump to content
Froxlor Forum
  • 0
sporkman

php mail() function OK, PHPMailer not OK

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?

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Don't know for WordPress, but in Froxlor its mostly due to an invalid email address in the settings

Share this post


Link to post
Share on other sites
  • 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?).

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...





×
×
  • Create New...