1

因此,当我提交表单时,一切都很好地存储在数据库中,我收到了一封非常简单的电子邮件,基本上包含“嘿,谢谢,这是你的链接”之类的交易,我收到了就好了。但是现在我已经升级为使用 HTML 正文,突然我没有收到电子邮件,知道为什么吗?

$to = $username;
$subject = 'Thanks for Registering on Dota Pub Stars!';
$message = '<html>
                <head>
                    <title>Registration Successful!</title>
                    <link rel="stylesheet" src="http://www.sithhappens.net/css/style.css" />
                </head>
            <body class="bodybg">
                <div id="registrationform">
                <p class="success">Thanks for registering on Dota Pub Stars!</p>
                <br />
                <br />
                <a class="button2" href="http://www.sithhappens.net/?key=' . $activation_key . '&amp;username=' . $username . '&amp;email=' . $email1 . '">Activate Account</a>
                </div>
            </body>
            </html>';

$headers = "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: $from\r\n";

mail($to, $subject, $message, $headers);
4

4 回答 4

1

你上面的代码工作正常我像这样检查尝试检查$username值是电子邮件

我的例子

$to = 'rsharma@gmail.com';
$subject = 'Thanks for Registering on Dota Pub Stars!';
$message = '<html>
                <head>
                    <title>Registration Successful!</title>
                    <link rel="stylesheet" src="http://site...net/css/style.css" />
                </head>
            <body class="bodybg">
                <div id="registrationform">
                <p class="success">Thanks for registering on Dota Pub Stars!</p>
                <br />
                <br />
                <a class="button2" href="http://www.site...net/activateacc.php?key=345345&amp;username=435345&amp;email=34534534">Activate Account</a>
                </div>
            </body>
            </html>';

    $headers = "MIME-Version: 1.0 \r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\n";
    $headers .= "From: $from\r\n";

mail($to, $subject, $message, $headers);

还要检查您的 SMTP 设置是否正常

于 2013-02-01T04:20:24.160 回答
0

您的服务器可能是 cAse-SEnSitive ...另外,添加 From

   $headers="From: $from\r\n";
   $headers.="Content-Type: text/html;charset=iso-8859-1\n";
   mail($to, $subject, $message, $headers);
于 2013-02-01T04:05:25.290 回答
0

请从 $to 末尾删除尾随逗号“,”

它应该是$to = $username;

并确保 $username 是电子邮件地址

于 2013-02-01T04:06:47.153 回答
0

您可以尝试通过\n而不是分隔标题\r\n,不要混合它们并且不要在标题字符串的末尾包含一个。

于 2013-02-01T04:18:38.493 回答