What are the potential vulnerabilities in the provided PHP script, especially in terms of email validation?
The potential vulnerability in the provided PHP script is that it uses a basic email validation check that is not robust enough to catch all possible email formats. To solve this issue, it is recommended to use a more comprehensive email validation method that adheres to RFC standards.
// Improved email validation using filter_var
$email = $_POST['email'];
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo "Invalid email format";
} else {
// Proceed with sending email
}