2015-04-23 45 views
0

我有一個郵件腳本工作正常,我無法弄清楚是什麼改變了這不會導致「發」通過。

我有這樣的代碼在郵件功能

$to = ($_POST['email']); 
$subject = 'Welcome to the Team!'; 
$url = 'mydomain.com'; 
$headers = "From: [email protected]\r\n"; 
$headers = "BCC: [email protected]\r\n"; 
$headers = "MIME-Version: 1.0\r\n"; 
$headers = "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
... 
mail($to, $subject, $message, $headers); 

的問題是,當電子郵件來過, 「從」 是這樣的:

來源:(MYDOMAIN)@( someLetters,方法&號).shr.phx3。(爲myhost).NET

的,而不是...

來源:[email protected]

這是怎麼回事?


全代碼更新

... 
if(count($errors) == 0) { 
$to = '[email protected]'; 
$subject = 'Subject'; 
$headers = "From: [email protected] mydomain.com\r\n"; 
$headers = "BCC: [email protected] mydomain.com\r\n"; 
$headers = "MIME-Version: 1.0\r\n"; 
$headers = "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
$message = "<html><body>…Email Message 1…</body></html>"; 
mail($to, $subject, $message, $headers); 
} 
if(count($errors) == 0) { 
$to = ($_POST['email']); 
$subject = 'Subject'; 
$url = 'mydomain.caom'; 
$headers = "From: [email protected] mydomain.com\r\n"; 
$headers = "BCC: [email protected] mydomain.com\r\n"; 
$headers = "MIME-Version: 1.0\r\n"; 
$headers = "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
$message = "<html><body>…Email Message 2…</body></html>"; 
mail($to, $subject, $message, $headers); 
echo '<META HTTP-EQUIV=Refresh CONTENT="1; URL='.$url.'">'; 
} 
+1

@B麥卡錫,因爲你只是覆蓋你的'$ headers'每時間,試着將它與'$ headers.'連接起來,參見後面的'.'。 –

回答

4

你的頭被打破,需要使用第一次申報後點被連接在一起:

$headers = "From: [email protected]\r\n"; 
$headers .= "BCC: [email protected]\r\n"; 
$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 

諮詢手冊:


編輯:

重命名你的第二組首部以$headers,例如:

if(count($errors) == 0) { 
$to = '[email protected]'; 
$subject = 'Subject'; 
$headers = "From: [email protected] mydomain.com\r\n"; 
$headers .= "BCC: [email protected] mydomain.com\r\n"; 
$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
$message .= "<html><body>…Email Message 1…</body></html>"; 
mail($to, $subject, $message, $headers); 
} 
if(count($errors) == 0) { 
$to = ($_POST['email']); 
$subject = 'Subject'; 
$url = 'mydomain.caom'; 
$headers2 = "From: [email protected] mydomain.com\r\n"; 
$headers2 .= "BCC: [email protected] mydomain.com\r\n"; 
$headers2 .= "MIME-Version: 1.0\r\n"; 
$headers2 .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
$message = "<html><body>…Email Message 2…</body></html>"; 
mail($to, $subject, $message, $headers2); 
echo '<META HTTP-EQUIV=Refresh CONTENT="1; URL='.$url.'">'; 
} 
+0

這會導致問題。我運行兩個獨立的郵件功能/電子郵件消息,當我使用'。='時,它會將消息A和消息B傳遞給兩個收件人。 –

+0

@BMcCarthy你需要發佈完整的代碼。那'''可以是任何東西。 –

+0

我已更新擴展的代碼。請查閱。謝謝! –