0

请任何人参考此代码并为我更正。我已经在另一个正在运行的网页中使用了这个代码,但是现在这个脚本没有发送消息,它显示了我的自定义错误消息。

你能请任何人帮我找到问题吗

谢谢

   <?php

        /* for admin */
        $registration_subject="Live demo registration";
        $registration_office="info@xxx.com";

        /* REGISTER details */

        $bizname = $_POST['txtbizname'];
        $biztype = $_POST['cbobiztype'];
        $address = $_POST['TxtAddress'];
        $city = $_POST['TxtCity'];
        $country = $_POST['cboCountry'];
        $tel = $_POST['TxtTel'];
        $fax = $_POST['TxtFax'];
        $email = $_POST['TxtEmail'];
        $web = $_POST['TxtWeb'];    
        $title = $_POST['Cbotitle'];
        $contname = $_POST['txtcontname'];
        $designation = $_POST['TxtDesignation'];
        $mob = $_POST['TxtMob'];
        $contemail = $_POST['TxtcontEmail'];
        $callbiztime = $_POST['BizGMT'];


        $body = <<<EOD
    Business Name : $bizname <br>
    Business Type : $biztype <br>
    Address : $address <br>
    City : $city <br>
    Country : $country <br>
    Tel : $tel <br>
    Fax : $fax <br>
    Email : $email <br>
    Web : $web <br>
    Title : $title <br>
    Contact Person Name : $contname <br>
    Designation : $designation <br>
    Mobile : $mob <br>
    Email : $contemail <br>
    Call Me at : $callbiztime <br>

    EOD;


        $headers = "From : $email\r\n";
        $headers = "Content-type:text/html\r\n";
        $mail_status = mail($registration_office, $registration_subject, $body, $headers);

    if ($mail_status) { ?>
        <script language="javascript" type="text/javascript">
            alert('Thank you for the message. We will contact you shortly.');
            window.location = 'b2b.html';
        </script>
    <?php
    }
    else { ?>
        <script language="javascript" type="text/javascript">
            alert('Message failed. Please, send an email to info@xxx.com');
            windowwindow.location = 'b2b.html';
        </script>
    <?php
    }
    ?>
4

3 回答 3

1

你有:

$headers = "From : $email\r\n";
$headers = "Content-type:text/html\r\n";

您需要将第二行连接到第一行:

$headers  = "From : $email\r\n";
$headers .= "Content-type:text/html\r\n";

请参阅http://php.net/manual/en/function.mail.php - 您需要指定一个“发件人”地址,该地址将丢失,因为您当前正在将其替换为“内容类型”行。

于 2013-06-12T10:32:20.543 回答
0

尝试error_reporting(E_ALL) 在脚本顶部设置并检查页面或错误日志中的任何错误。如果您仍然有问题,只需发布​​您收到的错误。

于 2013-06-12T10:30:05.207 回答
0

评论您的代码并尝试使用一些硬编码值来检查邮件是否正常工作:

mail("test@test.com", "My Subject", "blablabla");

如果它不起作用,您的邮件服务器有问题

于 2013-06-12T10:32:03.347 回答