dtpwra8456 2013-01-08 18:11
浏览 48

php邮件没有发送到电子邮件

 <!DOCTYPE html>

<html>

<head>

    <link href="aadab.css" rel="stylesheet" type="text/css">
    <link rel="icon" href="images/favicon.png">

</head>

<body>

<h2>REGISTRATION FORM</h2>

<div id="form">

<?php

if(isset($_POST['submit']))
    {

        $name= $_POST['name'];
        $phone= $_POST['phone'];
        $email= $_POST['email'];
        $college= $_POST['namecolg'];
        $team= $_POST['team'];
        $im= $_POST['im'];
        $detail= $_POST['detail'];
        $subject= 'Registration for aadab 2013';

        if ( (empty($name)) || (empty($phone)) || (empty($email)) || (empty($college)) || (empty($detail)) )
            {
                echo '<p id="fillall">It is necessary that you fill at least the required fields that are marked with a star</p>';
            }
        else
            {
                $to= 'xyz@gmail.com';
                $con= "<b>Registration Details:</b><br>"."Name: $name<br>"."Contact: $phone<br>"."Email: $email<br>"."College: $college<br>"."Team(if any): $team<br>"."Instant message: $im<br>"."Details of the event(s): $detail<br>";

                $emsg= "Registration Details:

"."Name: $name
"."Contact: $phone
"."Email: $email
"."College: $college
"."Team(if any): $team
"."Instant message: $im
"."Details of the event(s): $detail
";   

                $msg = wordwrap($emsg,70);

                $mailsend= mail($to, $subject, $msg);

                if ($mailsend)
                {
                    echo "<div class=\"regdet\"><b>Here is what you've submitted:</b><br><br>$con";
                    echo '<br>Congratulations! You have successfully registered! Click <a href="index.html">here</a> to continue.</div>';
                }
                else
                {
                    echo '<div class="regdet"><br>OOPS! Something went wrong. Click <a href="form.php">here</a> to try again.</div>';
                }
            }
    }
else
    {?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" autocomplete="on" method="post">

    <table>


        <tr>
            <th><label for="name">Your fullname*</label></th>
            <td><input type="text" id="name" name="name" value="<?php echo $name; ?>" required></td>
        </tr>

        <tr>
            <th><label for="phone">Your contact number*</label></th>
            <td><input type="tel" id="phone" name="phone" value="<?php echo $phone; ?>" required></td>
        </tr>

        <tr>
            <th><label for="email">Your email-id*</label></th>
            <td><input type="email" id="email" name="email" value="<?php echo $email; ?>" required></td>
        </tr>

        <tr>
            <th><label for="namecolg">Name of your college*</label></th>
            <td><input type="text" id="namecolg" name="namecolg" value="<?php echo $college; ?>" required></td>
        </tr>

        <tr>
            <th><label for="team">The name of your team<br>(if registering for a team event)</label></th>
            <td><input type="text" id="team" name="team" value="<?php echo $team; ?>" ></td>
        </tr>

        <tr>
            <th><label for="im">Bbm pin/iMessage id/Whatsapp<br>(if any, separate each id by a comma)</label></th>
            <td><input type="text" id="im" name="im" value="<?php echo $im; ?>" ></td>
        </tr>

        <tr>
            <th><label for="detail">Details of the event(s) you want to register for*</label></th>
            <td><input type="text" id="detail" name="detail" value="<?php echo $detail; ?>" required></td>
        </tr>

        <tr><td colspan="2" style="text-align: center; padding: 40px 0px 0px 0px;"><input type="submit" name="submit" value="Register"></td</tr>

    </table>


</form>

<?php } ?>

</div>


</body>

</html>

this piece of script has baffled me for two days ! i am unable to find a bug which is not allowing me to send an email to my email id

firebug also does not show any warnings or error i checked phpcodechecker.com for possible syntax errrors but nothing came up

im unable to receive maill from neither a live server nor my local zend server in both cases i get the "else" echo statement..

  • 写回答

3条回答 默认 最新

  • dqrqp8492 2013-01-08 18:21
    关注

    This is the function for sending mail in PHP:

    mail(to,subject,message,headers,parameters)
    

    to, subject and message are all required parameters. You are missing a subject.

    headers and parameters are optional

    For additional details on how to use the mail() function, see: http://php.net/manual/en/function.mail.php

    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line