php函數-mail時要注意的事

今天遇到一個小問題

客戶那邊寄的信沒有顯示’寄件者’

但是我用雷鳥收信有看到

之後才發現原因

當雷鳥收信沒有’寄件者’時

會顯示寄件的伺服器的系統mail

例如 apache@www4.vh.com.tw

(有錯請指正)

則在一些webmail和outlook上則是顯示空白

之後我去看程式才發現他寄信時送出的header

在 From: 的位置是空的
    

 

$subject = "Customer Order from $GV_WebHost";
 $headers = "MIME-Version: 1.0\r\n";
 $headers.= "Content-type: text/html; charset=big5\r\n";
 $headers.= "From: \r\n";
 $headers.= "To:  \r\n";
 $headers.= "Reply-To: \r\n";
 $headers.= "X-Priority: 1\r\n";
 $headers.= "X-MSMail-Priority: High\r\n";
 $headers.= "X-Mailer: Just My Server";



 

加上去之後就ok了

 

$headers.= "From: zoearthmoon@gmail.com \r\n";

 

嗯嗯

有錯請指正

感恩!