You can use PHP filters to validate emails with PHP - FILTER_VALIDATE_EMAIL.
FILTER_VALIDATE_EMAIL
$email = $_POST['email'] ?? null; if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error = 'Invalid email'; }