写了一个简单的发送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' . "\r\n";
- $headers .= 'Content-type: text/html; charset=gb2312' . "\r\n";
- $headers .= 'From: ' . $from . "\r\n";
- mail($to, $subject, $message, $headers);
- }
- ?>