【问题标题】:Sending a confirmation email to users向用户发送确认电子邮件
【发布时间】:2013-03-27 20:40:26
【问题描述】:

我正在尝试在用户注册我的网站时向他们发送一封包含确认码的电子邮件。电子邮件发送正常,但是当我输入完整的 URL 时,邮件没有发送

在这里你可以看到我正在使用的代码:

    $message = 'You have recieved this email because you have signed up to Amped. To complete the registration process, please
click on the link below. <br/> <a href=confirm.php?code=' . $row['emailcode'] . '>Click here to complete registration</a>'

我需要在 confirm.php 之前输入完整的 url 以使链接正常工作,但是当我这样做时,电子邮件不会发送。有什么想法吗?

【问题讨论】:

  • 你用的是什么库?只是mail() 或更复杂的东西?
  • 你是什么意思“电子邮件不发送”。这可能是垃圾邮件过滤器的问题吗?您的域中是否有正确的 spf / 域密钥条目?您是否尝试过先手动发送相同的电子邮件。

标签: php mysql email


【解决方案1】:

您发送的是相对路径。您需要使用urlencode 发送文件的整个路径:

$message = '<a href="' . urlencode("http://www.example.com/confirm.php?") . $row['emailcode'] . '">';

【讨论】:

    【解决方案2】:

    您缺少引号:

     $message = 'You have recieved this email because you have signed up to Amped. To complete the registration process, please click on the link below. <br/> <a href="confirm.php?code=' . $row['emailcode'] . '">Click here to complete registration</a>'
    

    【讨论】:

      【解决方案3】:

      您应该确保清理该 url 变量,对其进行编码以确保 url 使用安全,然后在 confirm.php 中对其进行解码。将 db 值直接回显到 url 不是一个好主意。 urlencode() 是一个不错的解决方案。不这样做可能会导致 URL 中断,进而导致您的脚本中断。

      $code = urlencode($row['emailcode']);
      
      $msg = "stuff.. <a href='http://www.example.con/confirm.php?code=". htmlentities($code) ."'>Click here</a>";
      

      【讨论】:

        猜你喜欢
        • 2011-07-19
        • 2023-03-14
        • 1970-01-01
        • 1970-01-01
        • 2021-01-06
        • 2020-06-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多