I'm seeking guidance on email SMTP verification.
I attempted to use PHPMailer to identify invalid recipients, but it wasn't successful. I also used sockets, but I get the same response even when the user doesn't exist.
Can anyone provide a solution to resolve this issue? Your help is much appreciated.
Thanks!
function rcpt($recipient)
{
fputs($this->smtp_conn, "MAIL FROM: <[email protected]>\r\n");
echo "FROM " . fgets($this->smtp_conn, 1024);
fputs($this->smtp_conn, "RCPT TO: <$recipient>\r\n");
echo "TO " . fgets($this->smtp_conn, 1024);
fputs($this->smtp_conn, "QUIT\r\n");
echo "QUIT: " . @fgets($this->smtp_conn, 1024);
fclose($this->smtp_conn);
}
function verifySMTP($email){
try {
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smp.server.fr';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'password/password';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->SMTPDebug = 3;
$mail->setFrom('[email protected]', 'sender');
$mail->CharSet = 'UTF-8';
$mail->SetLanguage('en', 'phpmailer/language/');
// Email content
$mail->isHTML(true);
$mail->Subject = 'Test Subject';
$mail->Body = 'This is a test email message.';
if ($mail->smtpConnect()) {
return $mail->getSMTPInstance()->rcpt($email);
} else {
echo $mail->ErrorInfo;
$mail->smtpClose();
}
} catch (\Throwable $ex) {
throw $ex;
}
}