use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; $email = "example@example.com"; // Create a new PHPMailer object $mail = new PHPMailer(); // Check if the email address is invalid if(!$mail->validateAddress($email)) { echo "Invalid email address"; } else { echo "Valid email address"; }
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; $emails = ["example@example.com", "invalid@address"]; // Create a new PHPMailer object $mail = new PHPMailer(); // Loop through each email address and check if it is valid foreach($emails as $email) { if(!$mail->validateAddress($email)) { echo "Invalid email address: ".$email; } }
use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; $email = "invalid@address"; // Create a new PHPMailer object $mail = new PHPMailer(); // Set a custom error message $mail->validateAddress($email, "Email address is invalid"); // Output the error message echo $mail->getCustomError();In conclusion, Mail ValidEmail is a useful PHP library for validating email addresses, and it is a part of the PHPMailer package. It provides functions for checking if an email address is valid, and it can also be used to set custom error messages.