所以我做了一個發送電子郵件的腳本,它使用了post方法,因爲它使用另一種編寫信息的編程語言,並且php接收併發送它。現在這個工作一直持續到幾個嘗試後,它還沒有發送?沒有收到任何東西,我不記得改變它。我的PHP電子郵件腳本不工作?
這裏是腳本:
<?php
if(isset($_POST['username'])) {
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['username']) ||
!isset($_POST['emailto']) ||
!isset($_POST['emailsubject']) ||
!isset($_POST['emailmessage'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$username = $_POST['username']; // required
$emailto = $_POST['emailto']; // required
$emailsubject = $_POST['emailsubject']; // required
$emailmessage = $_POST['emailmessage']; // required
$error_message = "";
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$username)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($emailsubject) < 2) {
died($error_message);
}
if(strlen($emailmessage) < 2) {
died($error_message);
}
$email_message = "This information was sent by a computercraft user:\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Username: ".clean_string($username)."\n";
$email_message .= "Subject: " .clean_string($emailsubject)."\n";
$email_message .= "Message: \n".clean_string($emailmessage)."\n";
// create email headers
$headers = 'From: ' . $username . "\r\n".
'Reply-To: '.$username."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($emailto, $emailsubject, $email_message, $headers);
?>
{
"True",
}
<?php
}
?>
Array
( [型] => 8 [消息] =>未定義變量:評論 [文件] => /客戶/ C/5/1/dannysmc .com/httpd.www/ccdb/email.php [line] => 31 )
// mail($ emailto,$ emailsubject,$ email_message,$ headers);
?>
{ 「真」, }
我在底部爲被接收它需要該類型表的程序添加一個真正的表。
如果你能幫助將是巨大的,感謝
什麼錯誤你得到 – 2014-10-29 09:34:56
你在公共服務器上? – pbaldauf 2014-10-29 09:39:38
PHP Mail不能在本地主機上工作 – 2014-10-29 09:40:09