Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 11:19:37
Original
905 people have browsed it

在php中自带了邮箱发送函数mail()我们可以直接使用此函数进行邮件发送,下面我来介绍一些常用的邮箱发送实例,最简单的就是mail函数了。  

 代码如下 复制代码

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);
}
?>
@s135.com>

提示

要使用的程序是由 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


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!