好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

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

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

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

例,代码如下:

<?php  function  send_mail( $from ,  $to ,  $subject ,  $message )  {       if  ( $from  ==  "" )      {           $from  =  '回忆未来 <webmaster@s135.com>' ; //发件人地址       } //开源软件:phpfensi.com        $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

查看更多关于利用php中mail函数发送HTML邮件实例 - php函数的详细内容...

  阅读:43次