Skip to content

Commit

Permalink
Update safe-mail.php
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHolbrook authored Aug 23, 2018
1 parent 89f11a4 commit b1e4e40
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/safe-mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b1e4e40

Please sign in to comment.