Home > php教程 > php手册 > 动态网页技术PHP写mail函数的注意事项

动态网页技术PHP写mail函数的注意事项

WBOY
Release: 2016-06-21 09:01:22
Original
1274 people have browsed it

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

$tomail='webmaster@webjx.com';
$name='webjx';
$text='webjx.com is a very good web!!';
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 = me@example.com

配置后

[mail function]
; For Win32 only.
SMTP = smtp.tom.com //指定你的邮箱smtp
smtp_port = 25
; For Win32 only.
sendmail_from = webmaster@webjx.com //你所使用的邮箱

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

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



Related labels:
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