Reputation: 11
I have included the following code to delete the user if the email is not sent but for some reason, even though when I supplied an invalid email such as [email protected], it is still sending it through, is there a way to prevent this?
$mail->addAttachment('images/phpmailer_mini.png');
if ($mail->send()) {
echo "<meta http-equiv='refresh' content='0;url=../student_registration.php?id=".htmlspecialchars($userid)."&email=".htmlspecialchars($email)."&username=".htmlspecialchars($uid)."'>";
// header("Location: ../student_registration.php?id=".htmlspecialchars($userid)."&email=".htmlspecialchars($email)."&username=".htmlspecialchars($uid)."");
} else {
echo "Mailer Error: " . $mail->ErrorInfo;
$sql13 = "DELETE FROM users WHERE user_uid = ? AND user_email = ?;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql13)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "ss", $username, $email);
mysqli_stmt_execute($stmt);
Upvotes: 0
Views: 73
Reputation: 10903
Most email/smtp server use accept before send
policy. Your message will be accepted by the server before any (instant) delivery attempts to next server in the delivery chain.
AFAIK On most servers during "submission for sending" you may get errors about invalid recipient's domain (missing MX
, A
and AAAA
records), invalid format of the recipient's email addresses but no reports about non exiting email account (on the final server).
Upvotes: 1