php 寄送 email 的方式

server 設定好後,像這樣寄信就可以了。

  1. $sCharset = 'big5';   
  2.   
  3. //@ 要送給誰   
  4. $sMailTo = '[email protected]';   
  5. //@ 誰送的   
  6. $sMailFrom = '[email protected]';   
  7. //@ 信件的主旨   
  8. $sSubject = "This is an MIME/HTML format email";   
  9. //@ 信件內容   
  10. $sMessage = "   
  11. <h1>信件內容: 這是一封 HTML 格式的 email</h1>   
  12. 這裡可以用任何 <strong>HTML 語法</strong>   
  13. ";   
  14.   
  15. //@ 為了傳送 HTML 格式的 email, 我們需要設定 MIME 版本和 Content-type header 內容.   
  16. $sHeaders = "MIME-Version: 1.0\r\n" .   
  17.             "Content-type: text/html; charset=$sCharset\r\n" .   
  18.             "From: $sMailFrom\r\n";   
  19.   
  20. //@ 傳送 email   
  21. mail($sMailTo$sSubject$sMessage$sHeaders);  

留言