2015-10-13 161 views
-4

我想用這段代碼發送表單的詳細信息到多個電子郵件地址,它不工作,任何人都可以教我我在哪裏出錯了請。我的最後一個問題被標記爲重複,但它沒有回答我的問題,請幫助我。運行時不會發送到任何電子郵件地址。我在哪裏出錯這個代碼

<?php 

$EmailFrom = "WelcomeToFarla,"; 
$EmailTo = array('[email protected]' , '[email protected]' , '[email protected]'); 
$Subject = "Online Form Submission"; 
$Name = Trim(stripslashes($_POST['Name'])); 
$Email = Trim(stripslashes($_POST['Email'])); 

// validation 
$validationOK=true; 
if (!$validationOK) { 
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; 
    exit; 
} 

// prepare email body text 
$Body = ""; 
$Body .= "Name: "; 
$Body .= $Name; 
$Body .= "\n"; 
$Body .= "Email: "; 
$Body .= $Email; 
$Body .= "\n"; 

// send email 
$success = ($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); 

// redirect to success page 
if ($success){ 
    print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">"; 
} 
else{ 
    print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">"; 
} 
?> 
+0

您需要在數組轉換爲字符串($ EmailTo)。 – sinisake

+0

嗨沒關係,感謝您的回覆,我以爲id試過,但它沒有工作,並在即將失去如何調整此腳本 –

+0

你不是說什麼不工作。請不要使用任何地址?一些?所有,但不一致?你做了什麼調試?你有沒有嘗試過使用一個地址,而不是數組?那樣有用嗎? – andrewsi

回答

3

除非您的代碼被意外截斷,否則實際上並沒有調用郵件功能。這:

// send email 
$success = ($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); 

應該是這樣的:

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");