Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用post方法发送邮件_Php_Email_Post - Fatal编程技术网

Php 使用post方法发送邮件

Php 使用post方法发送邮件,php,email,post,Php,Email,Post,我想向用户发送邮件,但当我单击“提交”按钮时,电子邮件未发送,我收到一个错误,表明请求未发送。这是我的密码 <?php include('submit.php'); if(isset($_POST['submit'])) { extract($_POST); $to = "chintan.suthar777@gmail.com"; $subject = "Email template"; $message = file_get_contents(

我想向用户发送邮件,但当我单击“提交”按钮时,电子邮件未发送,我收到一个错误,表明请求未发送。这是我的密码

<?php
include('submit.php');

 if(isset($_POST['submit']))
 {
    extract($_POST); 
    $to = "chintan.suthar777@gmail.com"; 
    $subject = "Email template";
    $message =  file_get_contents('index.php');              
    $headers = 'MIME-Version: 1.0'."\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1'."\r\n";
    $headers .= "From: chintan.suthar777@gmail.com";
    $mail_sent = mail($to, $subject, $message, $headers);  

    if($mail_sent)
        echo "<script>alert('Thank you. we will get back to you');
           window.location='index.php';exit();</script>";
    else
        echo "<script>alert('Sorry.Request not send');
           window.location='index.php';exit();</script>";

    }
?>
我的HTML代码如下:

<form name="news_data" action="email.php" method="post" enctype="multipart/form-data">
<table width="100%">
    <tbody>
        <tr>
            <td><h3>News </h3></td><td><input type="text" readonly value="1" name="sec_1_new[]" id="sec_1_new_1"  /></td>
        </tr>

        <tr>
             <td>Title of news :</td>
             <td><input type="text"  name="sec_1_title_news[]" id="sec_1_title_news_1" /><br /><br /></td>
         </tr>

         <tr>
             <td>Description: </td>
             <td><textarea rows="5" cols="30" name="sec_1_desc[]" id="sec_1_desc_1" ></textarea><br /><br /></td>
        </tr>

        <tr>
             <td>Title of Link :</td>
             <td><input type="text" name="sec_1_newslink[]" id="sec_1_newslink_1"  /><br /><br /></td>
         </tr>

          <tr>
            <td>URL of News:</td>
            <td><a href="#"><input type="text" name="sec_1_news_url[]" id="sec_1_news_1_url" /><br /><br /></a></td>
         </tr>

         <tr>
              <td>News image:</td>
              <td><input type="file" name="sec_1_news_img[][]" id="sec_1_news_1_image" ><br /><br /></td>
          </tr>

          <tr>
              <td></td>
              <td align="right"><input class="add" type="button" value="Add" id="sec_1_news_1_add" onClick="add_new(this.id)" /></td>

         </tr>
      </tbody>
   </table>
<input type="submit" name="submit" value="Submit" />
</form>

检查邮件是否以“.”开头,因为邮件已被删除,因此请使用str_replace\n、\n..、$text;
检查您的$message是否大于70个字符add$message=wordwrap$message,70,\r\n

同时添加一个表单HTML检查您的服务器是否支持邮件发送功能。使用HTML代码编辑仍然会收到相同的错误。您可以写入所有错误吗?与错误不同,但如下所示:回显警报“抱歉。请求不发送”;window.location='index.php';出口抱歉的警告。请求未发送我认为这是您的主机问题,请与支持您的主机连接