寫了一個簡單的發送HTML郵件的PHP函數。
函數說明:send_mail("發件人地址", "收件人地址", "郵件主題", "郵件正文");
示例:
- send_mail($from, [email protected], "這是郵件的主題", "<html><head></head><body><p><font color=red>這是郵件正文</font></p></body></html>");
代碼如下:
- <?php
- function send_mail($from, $to, $subject, $message)
- {
- if ($from == "")
- {
- $from = 呂滔 <[email protected]>;//發件人地址
- }
- $headers = MIME-Version: 1.0 . " ";
- $headers .= Content-type: text/html; charset=gb2312 . " ";
- $headers .= From: . $from . " ";
- mail($to, $subject, $message, $headers);
- }
- ?>