sendmail安装 检查有没有sendmail程序,在xampp安装目录下的sendmail文件夹下。没有则下载sendmail.zip,然后把它解压到如D:/php/sendmail/目录下。 配置步骤: 1.php.ini中如下设置: ; SMTP = localhost; smtp_port = 25; sendmail_from = sendmail_path = "C:/xampp/sendmail/sendmail.exe -t" 也就是注释掉"SMTP"、"smtp_port"、"sendmail_from",设置sendmail_path变量的值为以上所示(根据自己电脑上sendmail.exe的目录自行设置)。
2.sendmail.ini中如下设置 smtp_server=smtp.gmail.com smtp_port=587 smtp_ssl=TLS error_logfile=error.log debug_logfile=debug.log auth_username=user@gail.com auth_password=passwd
给予cmd.exe权限
C:/WINDOWS/system32/cmd.exe 文件以 users的读权限。不给予权限会出现以下错误。
Warning: mail() [function.mail]: Could not execute mail delivery program
测试代码:
<?php
$mail = “xxxx@sina.com.cn”;
$subject = “Mail Test”;
$text = “This is a test mail for function mail()”; if(mail($mail,$subject,$text)){
echo “email send success!”;
}else{
echo “email send fail!”;
}
?>
|