2013-03-01 35 views
-1

我試了幾個人的答案,沒有工作。我有一個很好的工作phpmail函數,我只想添加一個autorespond函數,以便發件人可以立即通知提交已收到。編碼自動回覆到phpmail

我的代碼是這樣的:

<?php 
     $mail_to_send_to = "[email protected]"; 
     $your_feedbackmail = "[email protected]"; 


     $sendflag = $_REQUEST['sendflag']; 
     if ($sendflag == "send") 
     { 
       $name = $_REQUEST['name'] ; 
       $email = $_REQUEST['email'] ; 
       $message = $_REQUEST['message'] ; 
       $headers = "From: $your_feedbackmail" . "\r\n" . "Reply-To: $name <$email>" . "\r\n" ; 
       $a = mail($mail_to_send_to, "Contact request", $message, $headers); 
       if ($a) 
       { 
        print("Message sent, thank you! You can send another"); 
       } else { 
        print("Message wasn't sent, please check that your email was filled in properly"); 
       } 
     } 
?> 

我想說的autorespond是這樣的:你想要什麼

Thank you for contacting us. This is an automatically generated reply confirming your submission. We will get back to you as soon as possible. 

Sincerely, 
John Doe 

回答

0

這是沒有明確,但我做胡亂猜測。您希望在用戶使用此表單時通過電子郵件發送郵件。使用此代碼:

<?php 

$mail_to_send_to = "[email protected]"; 
$your_feedbackmail = "[email protected]"; 


$sendflag = $_REQUEST['sendflag']; 

if ($sendflag == "send") { 
    $name = $_REQUEST['name'] ; 
    $email = $_REQUEST['email'] ; 
    $message = $_REQUEST['message'] ; 
    $headers = "From: $your_feedbackmail" . "\r\n" . "Reply-To: $name <$email>" . "\r\n" ; 
    $a = mail($mail_to_send_to, "Contact request", $message, $headers); 
    if ($a) 
    { 
     print("Message sent, thank you! You can send another"); 
     $message_back = "Thank you for contacting us. This is an automatically generated reply confirming your submission. We will get back to you as soon as possible."; 
     mail($email, "Contact request", $message_back, $headers); 
    } else { 
     print("Message wasn't sent, please check that your email was filled in properly"); 
    } 
} 

?> 
+1

與我在搜索中找到的其他答案一樣,此代碼添加呈現我的整個網頁無法訪問。如果我添加代碼,則Web瀏覽器無法訪問表單頁面,如果我將它取出,瀏覽器可以加載它。奇怪...有什麼想法? – mateikav 2013-03-02 01:40:08