【问题标题】:how to delete the user if the email is not a valid email如果电子邮件不是有效电子邮件,如何删除用户
【发布时间】:2019-12-23 18:46:02
【问题描述】:

如果电子邮件未发送但由于某种原因,我已包含以下代码以删除用户,即使我提供了无效电子邮件(例如 sdfsd@hotmail.com),它仍在发送它,是否有有什么办法防止这种情况发生?

$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);

【问题讨论】:

  • 我找不到任何关于此的答案,并尝试了以下代码但无法正常工作
  • if(checkdnsrr(array_pop(explode("@", $email)), "MS")) { echo "有效域"; } else { echo "无效域" }
  • 我想我应该使用某种预匹配和内爆函数?
  • 你的意思是它仍然向无效地址发送电子邮件?
  • 我将 $email 变量替换为“EmailAddress”,但仍然不起作用...我想除了让用户激活他或她的帐户以验证他们的电子邮件地址之外,别无他法

标签: php email smtp


【解决方案1】:

大多数电子邮件/smtp 服务器使用accept before send 策略。在尝试向传递链中的下一个服务器进行任何(即时)传递之前,服务器将接受您的消息。

AFAIK 在大多数服务器上“提交发送”期间,您可能会收到有关无效收件人域的错误(缺少 MXAAAAA 记录),收件人电子邮件地址格式无效但是 没有关于未退出电子邮件帐户的报告(在最终服务器上)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-15
    • 2018-04-16
    • 2019-07-04
    • 2010-12-08
    • 1970-01-01
    • 2021-04-14
    • 1970-01-01
    • 2014-02-09
    相关资源
    最近更新 更多