今天看书,看到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啊!
不过真是怪了,在单位写的就发送成功了,在家写一样一样的就没成功,大家来看看~~

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Linux new version
SublimeText3 Linux latest version
