邮寄表格 - 我没有收到电子邮件 [英] Post Form - I Didn't Receive Email

查看:125
本文介绍了邮寄表格 - 我没有收到电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以理解标签,我也成功编辑了一个名为GetSimple的CMS,所有的工作都很好(几个月前)。现在,经过几个月的时间,我开始这样做,不能通过...

I can understand tags a bit, also I´ve successfully edited a CMS named GetSimple and all works fine (few months ago). Now, after a couple of months I´ve started with this and cant go through...

我有一个成功发送的按摩...谢谢你联系我们,我们很快就会和你联系。但是我没有收到邮件。我尝试过互联网上不同的HTML和PHP示例,但这也是同样的问题。

I've got the massage of a successful send... "Thank you for contacting us. We will be in touch with you very soon. " but I didn't receive the mail. I've tried different HTML and PHP examples from the internet, but it's the same problem.

HTML

<form method="POST" action="send.php" class="left" enctype="text/plain">
    <input type="hidden" name="form-name" value="contact" />
    <fieldset>
        <label for="your_name">YOUR NAME *</label><input type="text"  id="your_name" name="your_name" class="required" /><br/>
        <label for="your_email">YOUR email *</label><input type="text" id="your_email" name="your_email" class="required email" /><br/>
        <label for="current_site">current site</label><input type="text" id="current_site" name="current_site" /><br/>
        <label for="estimated_budget">estimated budget</label><input type="text" id="estimated_budget" name="estimated_budget" /><br/>
        <label for="project_description">project description</label> <textarea id="project_description" name="project_description"></textarea><br/>
        <!--<input type="submit" value="send" id="sendbutton">  -->
        <button class="defaultButton small" id="quotebutton"><span class="buttonLabel">Send</span></button>
    </fieldset>
</form> 

PHP命名为send.php

PHP named "send.php"

<?php
if(isset($_POST['email'])) {


    $email_to = "mymail@gmail.com";

    $email_subject = "example subject";



    $your_name = $_POST['your_name']; // required
    $your_email = $_POST['your_email']; // required

    $error_message = "Please enter valid e-mail adress";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

  }

    $email_message = "Form details below.\n\n";

    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }

    $email_message .= "Name: ".clean_string($your_name)."\n";
    $email_message .= "Mail: ".clean_string($your_email)."\n";
    $email_message .= "Current site: ".clean_string($current_site)."\n";
    $email_message .= "Estimated budget: ".clean_string($estimated_budget)."\n";
    $email_message .= "Project description: ".clean_string($project_description)."\n";


// create email headers
$headers = 'From: '.$your_email."\r\n".
'Reply-To: '.$your_email."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?>
 } 
<!-- place your own success html below -->

Thank you for contacting us. We will be in touch with you very soon.

<?php
die();
?>


推荐答案

首先我想你缺少一些标头, / p>

First i think your missing some headers look at those

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

调用邮件功能时,请检查其是真还是假?

2nd check if its true or false when calling the mail function

if( mail($email_to, $email_subject, $email_message, $headers)!==true)
    {
        die('Fail to send');


    }
    die('Sucess');

    }

这篇关于邮寄表格 - 我没有收到电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆