2013-08-26 66 views
0

我需要添加一個條件。如果$contact_subject大於數字50000,它應該轉到一個電子郵件地址,如果它更小,它應該轉到另一個電子郵件地址。根據答覆發送到不同的電子郵件

if($contact_name == true) 
{ 
    $sender = $contact_email; 
    $receiver = "[email protected]"; 
    $client_ip = $_SERVER['REMOTE_ADDR']; 
    $email_body = "Name: $contact_name \nEmail: $sender \nAccount Number: $contact_subject \nMessage: $contact_message \nIP: $client_ip \nEmail Sent from website http://www.website.com";  
    $extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion(); 

    if(mail($receiver, "Email From Website - $subject", $email_body, $extra)) 
    { 
     echo "success=yes"; 
    } 
    else 
    { 
     echo "success=no"; 
    } 
} 
+0

您是否嘗試過使用if .... elseif語句? – Jim

+0

我並不擅長這一點。我將與Amal的建議合作。 – betti

+0

會讓你知道盡快Amal。 – betti

回答

0

也許更好的辦法是把大小放在可變數字中。

-> config.php 
    $size_mail = '5000'; 


-> mail.php 
include "config.php"; 
if($contact_name == true) 
    { 

    if($contact_subject > $size_mail) 
    {$receiver = '[email protected]';}else{$receiver == '[email protected]';} 

     $sender = $contact_email; 
     $client_ip = $_SERVER['REMOTE_ADDR']; 
     $email_body = "Name: $contact_name \nEmail: $sender \nAccount Number: $contact_subject \nMessage: $contact_message \nIP: $client_ip \nEmail Sent from website http://www.website.com";  
     $extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion(); 

     if(mail($receiver, "Email From Website - $subject", $email_body, $extra)) 
     { 
      echo "success=yes"; 
     } 
     else 
     { 
      echo "success=no"; 
     } 
    } 
+0

你們搖滾!非常感謝!我會嘗試。我不是很擅長這個,所以我非常感謝快速反應和幫助! – betti

相關問題