发送邮件时出现PHP错误

时间:2016-12-06 07:38:20

标签: php html email

我想通过php和html代码发送邮件。 我用html制作了表单。这是我的代码

<form name="contactform" method="post" action="send_form_email.php"> 
     <table width="450px">
          <tr>   
               <td valign="top">
                    <label for="first_name">First Name *</label>
                </td>
                 <td valign="top">
                    <input  type="text" name="first_name" maxlength="50" size="30">
                </td>
            </tr>
            <tr>
                <td valign="top"">
                    <label for="last_name">Last Name *</label>
                </td>
                <td valign="top">
                    <input  type="text" name="last_name" maxlength="50" size="30">
                </td>
            </tr>       
            <tr>
                <td valign="top">
                    <label for="email">Email Address *</label>
                </td>
                <td valign="top">
                    <input  type="text" name="email" maxlength="80" size="30">
                </td>
            </tr>
            <tr>
                <td valign="top">
                    <label for="telephone">Telephone Number</label>
                </td>
                <td valign="top">
                    <input  type="text" name="telephone" maxlength="30" size="30">   
                </td>
            </tr>
            <tr>
                <td valign="top">
                    <label for="comments">Comments *</label>
                </td>    
                <td valign="top">
                    <textarea  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align:center">
                    <input type="submit" value="Submit">Email Form
                </td>
            </tr>
        </table>
 </form>

之后我可以发送该电子邮件中的php文件中的代码。这是我的代码

<?php
    $name ="$first_name";
    $lastname ="$last_name";
    $telephone ="$telephone";
    $emailid ="$email";
    $comment ="$comments";

    //from
    $header ="from : $name <$emailid>";
    $to ="sonikaran006@gmail.com";

    $send_form_email =mail($to, $name, $lastname, $emailid, $telephone, $comment);

    if($send_form_email)
    {
    echo "We have received your information";
    }
    else
    {
    echo "Error";
    }   
?>

但是当我在那时运行表单时,它显示错误并在记事本中打印,如此

&#34 ;; $ to =&#34; sonikaran006@gmail.com" ;; $ send_form_email = mail($ to,$ name,$ lastname,$ emailid,$ telephone,$ comment); if($ send_form_email){echo&#34;我们已收到您的信息&#34 ;; } else {echo&#34; Error&#34 ;; }?&gt;

所以,我无法理解我的代码中出了什么问题。请帮我解决这个错误。 This is html form named "contactform"

This is error coming in php form named send_form_email。com / LidLK.png

0 个答案:

没有答案