diff --git a/HealthCheck/Tools/class-health-check-mail-check.php b/HealthCheck/Tools/class-health-check-mail-check.php
index d000b0c..498a241 100644
--- a/HealthCheck/Tools/class-health-check-mail-check.php
+++ b/HealthCheck/Tools/class-health-check-mail-check.php
@@ -16,6 +16,8 @@
*/
class Health_Check_Mail_Check extends Health_Check_Tool {
+ private $mail_error = null;
+
public function __construct() {
$this->label = __( 'Mail Check', 'health-check' );
$this->description = __( 'The Mail Check will invoke the wp_mail()
function and check if it succeeds. We will use the E-mail address you have set up, but you can change it below if you like.', 'health-check' );
@@ -35,13 +37,15 @@ public function __construct() {
*
* @return void
*/
- static function run_mail_check() {
+ public function run_mail_check() {
check_ajax_referer( 'health-check-mail-check' );
if ( ! current_user_can( 'view_site_health_checks' ) ) {
wp_send_json_error();
}
+ add_action( 'wp_mail_failed', array( $this, 'mail_failed' ) );
+
$output = '';
$sendmail = false;
$email = sanitize_email( $_POST['email'] );
@@ -81,6 +85,7 @@ static function run_mail_check() {
} else {
$output .= '
'; $output .= esc_html__( 'It seems there was a problem sending the e-mail.', 'health-check' ); + $output .= '
' . $this->mail_error->get_error_message(); $output .= '