一聚教程网:一个值得你收藏的教程网站

热门教程

利用php中mail函数发送HTML邮件实例

时间:2022-06-24 20:02:14 编辑:袖梨 来源:一聚教程网

 代码如下 复制代码

function send_mail($from, $to, $subject, $message)
{
    if ($from == "")
    {
        $from = '回忆未来 ';//发件人地址
    }
    $headers = 'MIME-Version: 1.0' . "rn";
    $headers .= 'Content-type: text/html; charset=gb2312' . "rn";
    $headers .= 'From: ' . $from . "rn";
    mail($to, $subject, $message, $headers);
}
?>

提示

要使用的程序是由 php.ini 文件中的配置设置定义的,邮件函数的行为受 php.ini 的影响,我们必须先配置才行。

名称          默认             描述                                                 可更改

SMTP          "localhost"      Windows 专用:SMTP 服务器的 DNS 名称或 IP 地址。         PHP_INI_ALL
smtp_port     "25"             Windows 专用:SMTP 段口号。自 PHP 4.3 起可用。           PHP_INI_ALL
sendmail_from NULL             Windows 专用:规定从 PHP 发送的邮件中使用的 "from" 地址。PHP_INI_ALL
sendmail_path NULL             Unix 系统专用:规定sendmail 程序的路径(通常 /usr/sbin/sendmail 或

/usr/lib/sendmail) PHP_INI_SYSTEM

热门栏目