Trim the email first. This prevents it from failing if there's a space
in start or end of the email that is being checked.
// Double check the email for valid address
$emails = explode( ',', $notify_to );
foreach ( $emails as $email ) {
- $validEmail = filter_var( $email, FILTER_VALIDATE_EMAIL );
+ $validEmail = filter_var( trim( $email ), FILTER_VALIDATE_EMAIL );
if ( !$validEmail ) {
return false;
}
}
// get the sender's email address and validate it
- $fromEmail = trim(filter_var($emailInfo['from_email'], FILTER_VALIDATE_EMAIL));
+ $fromEmail = filter_var( trim( $emailInfo['from_email'] ), FILTER_VALIDATE_EMAIL );
// get the email notification message
$emailNotification = ( isset($emailInfo['email_notification']) ? $emailInfo['email_notification'] : '' );