当前位置: 首页 > 图文教程 > 网络编程 > PHP > 用PHP写mail函数 配置好后需要重启apache

PHP
include()与require()的对比
php和asp对象的等价关系
PHP, JScript 和 VBScript 函数和类的语法
PHP:MVC迷思
PHP脚本的8个技巧(1)
PHP脚本的8个技巧(2)
PHP脚本的8个技巧(3)
PHP脚本的8个技巧(4)
PHP脚本的8个技巧(5)
PHP脚本的8个技巧(6)
PHP脚本的8个技巧(7)
PHP脚本的8个技巧(8)
PHP教程.经验技巧(上)
递归列出所有文件和目录
PHP的历史和优缺点
PHP下MAIL的另一解决方案
PHP文本数据库的搜索方法
PHP调用三种数据库的方法(1)
PHP调用三种数据库的方法(2)
PHP调用三种数据库的方法(3)

用PHP写mail函数 配置好后需要重启apache


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 90 ::
收藏到网摘: n/a

今天看书,看到mail函数,就自己练着写了个简单的程序。
<?php

$tomail='[email protected]';
$name='liuyu';
$text='you win!!';

if(mail($tomail,$name,$text)) //函数有5个参数前3个是必填参数。第一个参数表示目的地址,第二个                                参数表示为主题,第三个参数表示内容。
{
    echo 'ok';
}
else
{
    echo 'no';
}

?>
要注意的一点是,mail函数的使用,需要在php.ini里边配置。
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = [email protected]

配置后
[mail function]
; For Win32 only.
SMTP = smtp.tom.com //指定你的邮箱smtp
smtp_port = 25

; For Win32 only.
sendmail_from = [email protected] //你所使用的邮箱

配置好后要记得重启apache啊!

不过真是怪了,在单位写的就发送成功了,在家写一样一样的就没成功,大家来看看~~

原文地址:http://www.phpchina.com/?9136/action_viewspace_itemid_3514.html