• Resolved jfgrenier

    (@jfgrenier)


    Wordpress introduced since version 4.4.0 the wp_mail_failed hook after a phpmailerException is caught. Can you add this Hook at the end of the wp_mail function in main.php ?

    Also, on our end, we need the defaut catch exception in case some Gmail credentials have been removed from WP or Gmail account, or if the mail can’t be send in any way.

    Here’s how we edited the try&catch at the end of main.php

    try {
    		return $phpmailer->Send();
    	} catch ( phpmailerException $e ) {
    		$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
     		do_action( 'wp_mail_failed', new WP_Error( $e->getCode(), $e->getMessage(), $mail_error_data ) );
    		return false;
    	}
    	catch ( Exception $e ) {
    		$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
     		do_action( 'wp_mail_failed', new WP_Error( $e->getCode(), $e->getMessage(), $mail_error_data ) );
    		return false;
    	}

    Thanks

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘wp_mail_failed Hook’ is closed to new replies.