2014-02-17 91 views
0

我從一個PHP表單發送電子郵件,它傳遞的信息很好,但是因爲我添加了郵件優先級,表單將郵件傳遞到同一個電子郵件地址。從PHP發送電子郵件

例子:

$email = $row['SUBSCRIPTIONS_EMAIL_FROM']; --> [email protected] 

$emailto = $row['SUBSCRIPTIONS_EMAIL_TO']; --> [email protected] 

$subject = $row['SUBSCRIPTIONS_1ST_NOTICE_SUBJECT']; 

$headers = "From: $email"; 

$send = mail($emailto, $subject, $body, $headers); 

它提供了電子郵件,並從細從SQL

給定的電子郵件地址,但自從我加入了消息優先級附加頭:

$email = $row['SUBSCRIPTIONS_EMAIL_FROM']; --> [email protected] 

$emailto = $row['SUBSCRIPTIONS_EMAIL_TO']; --> [email protected] 

$subject = $row['SUBSCRIPTIONS_1ST_NOTICE_SUBJECT']; 

$headers = "From: $email"; 

$headers = "X-Priority: 1 (Highest)\n"; 

$headers = "X-MSMail-Priority: High\n"; 

$headers = "Importance: High\n"; 

$send = mail($emailto, $subject, $body, $headers); 

它將電子郵件發送到$emailto:電子郵件地址。

任何人都可以幫助我嗎?

在此先感謝。

+1

高興您收到的郵件...所以問題是什麼? –

+0

我怎樣才能讓它顯示正確的電子郵件地址 – user3303594

回答

3

兩件事情第一次見到我的眼睛:

  1. 您覆蓋您$頭多次:
  2. 您應該使用回車和新線分開行「\ r \ n」。

取而代之的是:

$headers = "From: $email"; 
$headers = "X-Priority: 1 (Highest)\n"; 
$headers = "X-MSMail-Priority: High\n"; 
$headers = "Importance: High\n"; 

嘗試串聯和使用適當的行分隔符:

$headers = "From: $email\r\n"; 
$headers .= "X-Priority: 1 (Highest)\r\n"; 
$headers .= "X-MSMail-Priority: High\r\n"; 
$headers .= "Importance: High\r\n"; 
+0

完美!這很好。沒有意識到我犯了這麼小的錯誤。謝謝你,很多萊夫 – user3303594