繁体   English   中英

php邮件表单不发送邮件

[英]php mail form doesn't send mail


我似乎对我正在制作的电子邮件表单有疑问。
表单正常工作,直到我添加了一些额外的部分。 然而,即使我评论我的更改,它也行不通。
我认为问题可能是由于某些语法错误,但似乎并非如此。
我没有收到任何错误消息
下面是我的代码:

<?php
if(isset($_REQUEST['email'])) {
    $num=$_REQUEST['num'];
    $desc=$_REQUEST['desc'];
    $subject="einak";
    $nomr=$_REQUEST['nomr'];
    $sphr=$_REQUEST['sphr'];
    $cylr=$_REQUEST['cylr'];
    $angr=$_REQUEST['angr'];
    $addr=$_REQUEST['addr'];
    $diar=$_REQUEST['diar'];
    $noml=$_REQUEST['noml'];
    $sphl=$_REQUEST['sphl'];
    $cyll=$_REQUEST['cyll'];
    $angl=$_REQUEST['angl'];
    $addl=$_REQUEST['addl'];
    $dial=$_REQUEST['dial'];
    $type=$_REQUEST['type'];
    $matter=$_REQUEST['matter'];
    $color=$_REQUEST['color'];
    $message=$num."<br />".$nomr."<br/>".$sphr."<br/>".$cylr."<br/>".$angr."<br />".$addr."<br />".$diar."<br />"."<br />".$noml."<br/>".$sphl."<br/>".$cyll."<br/>".$angl."<br />".$addl."<br />".$dial."<br />".$desc."<br />".$type."<br />".$matter."<br />".$color."<br />";
    $email='info@toosoptic.ir';
    $headers='MIME-Version: 1.0'."\r\n";
    $headers.='Content-type: text/html; charset=iso-8859-1'."\r\n";
    mail("mail@example.com",$subject,$message,$headers);
    echo "ارسال شما موفقیت آمیز بود";
} else {
    echo "<form method='post'>
                <input name='num' id='num' type='text' /> <br />
                <input type='text' name='nomr' id='nomr' > <br />
                <input type='text' name='sphr' id='sphr'> <br />
                <input type='text' name='cylr' id='cylr'  > <br />
                <input type='text' name='angr' id='angr'  > <br />
                <input type='text' name='addr' id='addr'  > <br />
                <input type='text' name='diar' id='diar' > <br />
                <input type='text' name='noml' id='noml' > <br />
                <input type='text' name='sphl' id='sphl'> <br />
                <input type='text' name='cyll' id='cyll'  > <br />
                <input type='text' name='angl' id='angl'  > <br />
                <input type='text' name='addl' id='addl'  > <br />
                <input type='text' name='dial' id='dial' > <br /> 
                <textarea id='desc' name='desc'> </textarea>          
                <input name='type' type='radio' value='bifocal' id='type1' />
                <input name='type' type='radio' value='progres' id='type2' />
                <input name='type' type='radio' value='single' id='type3' />
                <input name='type' type='radio' value='decen' id='type4' />
                <input name='matter' type='radio' value='glass' id='mat1' />
                <input name='matter' type='radio' value='plastic' id='mat2' />
                <input name='color' type='radio' value='single' id='col1' />
                <input name='color' type='radio' value='decen' id='col2' /> 
                <input type='submit' id='sb' value='ارسال اطلاعات' />
                <input type='text' name='name' id='name'  > <br />
                <input type='add' name='address' id='address'  > <br /> 
            </form >
            <p id='confirmation'></p>
            <input  type='submit'  id='vis' onClick='vis(); return false;'  value='تایید اطلاعات'/>";
}
?>

您还没有在提交按钮中定义名称:

 <input type='submit' id='sb' value='ارسال اطلاعات' />

用以下代码替换上面的代码:

 <input type='submit' id='sb' name='email' value='ارسال اطلاعات' />

您正在检查代码if(isset($_REQUEST['email']))并且我看到表格中没有电子邮件字段。

基本上,此检查用于验证表单是否已提交(通常是其他方式)。 因此,您需要在提交按钮属性中添加name='email'以执行if条件代码。

您正在设置mime标头,但您没有设置任何mime编码,这可能是一个问题;-)尝试使用专用软件包,如PEAR / Mail (和PEAR / Mail / Mime )或phpMailer

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM