• Resolved agrisv

    (@agrisv)


    Hi! After debugging email problems. i can confirm what phpmailerException in file class.phpmaileroauth.php dose not thrown, error not shows in logs or display.
    example if authentication failed, no error, and wp_mail_failed cant handle it.
    If i change it like \Exception then all are ok. exception are at logs and display.
    Example code:

    
    require('wp-load.php');
    $sent_message = wp_mail( $to, $subject, $message, $headers );
    

    gmail plugin for example put this

    
     throw new \phpmailerException($this->lang('authenticate'));
    

    after line for test line 65

    
     public function smtpConnect($options = array()) {
    

    First problem was plugin “WooCommerce PDF Invoices & Packing Slips” 2.2.14 witch result in gmail extension with failure at ($this->smtp->authenticate) send emails with authentication failed and no exception in logs.

    • This topic was modified 6 years, 11 months ago by agrisv.
    • This topic was modified 6 years, 11 months ago by agrisv.
    • This topic was modified 6 years, 11 months ago by agrisv.
Viewing 1 replies (of 1 total)
  • Thread Starter agrisv

    (@agrisv)

    And more info:
    1. Please enable error throw with “true” – without true no error on failure:

    
    $phpmailer = new PHPMailerOAuth(true); 
    

    2. set email validator to “php”. PHPMailer did it in version 6.x, because much emails are invalid with pcre8 validation. This was also our problem with Ubuntu 18 and php7.3.

    
    $phpmailer::$validator = 'php';
    

    3. Need email retry for timeout connection error for example 3 times, because on network error, email disappear.

    4. If you use your own PHPMailer class, maybe need reload class because.. If other plugin initialize PHPmailer class with wordpress default, then you get old version of class and your plugin not work.
    example from plugin “woocommerce-pdf-invoices-packing-slips”:

    
    // ww.wp.xz.cn/support/topic/invalid-address-setfrom/#post-11583815
    public function set_phpmailer_validator( $mailArray ) {
     if ( version_compare( PHP_VERSION, '7.3', '>=' ) ) {
     global $phpmailer;
     if ( ! ( $phpmailer instanceof \PHPMailer ) ) {
      require_once ABSPATH . WPINC . '/class-phpmailer.php';
      require_once ABSPATH . WPINC . '/class-smtp.php';
      $phpmailer = new \PHPMailer( true );
     }
     $phpmailer::$validator = 'php';
     }
    
     return $mailArray;
    }
    
Viewing 1 replies (of 1 total)

The topic ‘phpmailerException not throw’ is closed to new replies.