From b1e4e40353c0c7607cc801952262a624e586074f Mon Sep 17 00:00:00 2001 From: Aaron Holbrook Date: Thu, 23 Aug 2018 06:26:23 -0500 Subject: [PATCH] Update safe-mail.php --- src/safe-mail.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/safe-mail.php b/src/safe-mail.php index 6e988da..83612a4 100644 --- a/src/safe-mail.php +++ b/src/safe-mail.php @@ -16,12 +16,12 @@ function safe_mail( $to, $subject, $message, $headers = '', $attachments = [] ) // Looks like an invalid email address if ( count( $email_parts ) !== 2 ) { - return false; + throw new \Exception( "Unable to detect a valid email address: {$to}" ); } - // Couldn't find the TLD in the safe list, let's quietly bypass sending an actual mail and pretend like it worked + // Couldn't find the TLD in the safe list, throw an exception and bubble this up the chain if ( false === array_search( $email_parts[1], $safe_tlds ) ) { - return true; + throw new \Exception( "Did not send email to {$to} as it is not on the safe email list." ); } // Found a safe TLD, let's go ahead and let it send