1

我正在编写一个个人网站,但我的联系人有问题。如果您能帮我找出问题所在,我将不胜感激。

该网站的链接是 www.tiryakicreative.com,php 表单的代码如下:

<div id="form">
<form id="ajax-contact-form" action="contact_form/send_form_email.php…
<fieldset class="info_fieldset">
<div id="note"></div>
<div id="fields">
<label>Name</label>
<input class="textbox" type="text" name="name" value="" />
<label>E-Mail</label><input class="textbox" type="text" name="email" value="" />     
<label>Subject</label>
<input class="textbox" type="text" name="subject" value="" />
<label>Message</label>
<textarea class="textbox2" name="message" rows="5" cols="25"></textarea>
<label> </label><input class="button" type="image" src="send2.gif" id="submit"   Value="Send Message" />    
</div>
</fieldset>
</form>
</div>
</div>

这是给定 html 代码的 php 代码:

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

// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "ian_tiryaki@hotmail.com";
$email_subject = "New Email from Website";


function died($error) {
// ERROR CODE GOES HERE
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.";
echo $error."";
echo "Please go back and fix these errors.";
die();
}

// validation expected data exists
if(!isset($_POST['name']) || 
!isset($_POST['email']) ||
!isset($_POST['subject']) ||
!isset($_POST['message'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.'); 
}

$first_name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['subject']; // not required
$comments = $_POST['message']; // required

$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Z…
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The Name you entered does not appear to be valid.';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The subject you entered does not appear to be valid.';
}
if(strlen($comments) < 2) {
$error_message .= 'The message you entered do not appear to be valid.';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";

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

$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Subject: ".clean_string($telephone)."\n";
$email_message .= "Message: ".clean_string($comments)."\n";


// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); 
?>

<!-- include success html here -->

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

<?php
}
?>
4

3 回答 3

0

您是否在用户发送电子邮件后收到电子邮件?

于 2012-10-28T09:18:11.343 回答
0

尝试添加

error_reporting(E_ALL);

到脚本的顶部。

您也可以尝试从邮件命令中删除 @

mail($email_to, $email_subject, $email_message, $headers); 

因为这将抑制正在生成的任何错误。

它可能是一些简单的事情,例如禁用附加标头的 PHP 邮件功能(某些主机出于安全原因这样做),在这种情况下邮件功能将失败。

于 2012-10-28T09:21:56.450 回答
0

将此设置在您的操作表单中...您肯定会从这里收到邮件..虽然有错误,但您可能会使用下面的代码使用php发送邮件而不声明变量...比如

$email_to=$_POST['email'];
$email_subject=$_POST['subject'];
$email_message=$_POST['message'];
$headers=$_POST['title'];

    mail('$email_to', '$email_subject', '$email_message', '$headers');

否则使用下面的代码发送邮件

mail('$_POST['email']','$_POST['subject']','$_POST['message']','$_POST['title']');
于 2012-10-28T12:54:39.757 回答