Title: phpmailerException not throw
Last modified: June 21, 2019

---

# phpmailerException not throw

 *  Resolved [agrisv](https://wordpress.org/support/users/agrisv/)
 * (@agrisv)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/phpmailerexception-not-throw/)
 * 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](https://wordpress.org/support/users/agrisv/).
    -  This topic was modified 6 years, 11 months ago by [agrisv](https://wordpress.org/support/users/agrisv/).
    -  This topic was modified 6 years, 11 months ago by [agrisv](https://wordpress.org/support/users/agrisv/).

Viewing 1 replies (of 1 total)

 *  Thread Starter [agrisv](https://wordpress.org/support/users/agrisv/)
 * (@agrisv)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/phpmailerexception-not-throw/#post-11687718)
 * 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”:
 *     ```
       // wordpress.org/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.

 * ![](https://ps.w.org/gmail-smtp/assets/icon-128x128.png?rev=2432932)
 * [Gmail SMTP](https://wordpress.org/plugins/gmail-smtp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gmail-smtp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gmail-smtp/)
 * [Active Topics](https://wordpress.org/support/plugin/gmail-smtp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gmail-smtp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gmail-smtp/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [agrisv](https://wordpress.org/support/users/agrisv/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/phpmailerexception-not-throw/#post-11687718)
 * Status: resolved