2012-02-25 19 views
0

Iveは送信していない連絡フォームを持っていますが、メッセージが送信されていることを出力していますか?誰も問題を見ることができますか?PHPお問い合わせフォームは送信されませんか?

<?php 

$name = $_POST['name']; 
$email = $_POST['email']; 
$subject = $_POST['subject']; 
$message = $_POST['message']; 
$to = "[email protected]"; 

    //begin of HTML message 
    $message = " 
    From : $name, 
    Email: $email, 
    Subject: $subject, 
    Message: $message "; 
    //end of message 

    // To send the HTML mail we need to set the Content-type header. 
    $headers = "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$headers .= "From: Website Enquiry"; 


if (isset($_POST['name'])) { 

     // now lets send the email. 
    mail($to, $subject, $message, $headers); 

header('Location: ' . $_SERVER['HTTP_REFERER'] . '?e=Thankyou, we will be in touch shortly.'); 

} else { 
    header('Location: ' . $_SERVER['HTTP_REFERER'] . '?e=There was an error sending your message, Please try again.'); 
    } 

?> 
+2

[SwiftMailer](http://swiftmailer.org)の実装を検討してみませんか? – Treffynnon

+1

このサーバーにはSMTPプログラムがインストールされていますか? –

+0

はい、ロデリックは... – Liam

答えて

0

に変更しなければならないヘッダが構文的に正しいメールアドレスを持っていなければならない「から」。また、 "mail"関数の戻り値を確認する必要があります。

$header .= "From: Website Enquiry <[email protected]>"; 

PS:コードフォーマットを改善してください。

0

From:in $ headersにメールを入力してください。 $headers .= "From: [email protected]"様または $headers .= "From: Website Enquiry <[email protected]vider.com>"

そして、あなたは

if(mail(...)) { 
//success 
} 
else { 
//email failed 
} 
関連する問題