windows下配置php的mail模块
1、在windows下配置php的mail模块需要通过一个外部的SendMail组件来实现,组件在附件中,下载后将其解压;2、找到php的配置文件php.ini,在配置文件中找到
这个节点,这边有一个配置sendMail路径的属性,我这边配的是下面这个路径
sendmail_path = "e:/SendMail/sendmail.exe -t -i"
3、配置sendMail的配置文件,在解压好的SendMail文件夹中,有一个sendmain.ini的配置文件,这边可以配置你的邮箱的smtp服务器,以及相应的用户名和密码,当php调用发邮件的方法的时候就是通过这边配置的邮箱来发邮件的
smtp_server=mail.sohu.com #smtp服务器地址
error_logfile=error.log #错误日志文件
auth_username=xxxx@sohu.com #邮箱用户名
auth_password=xxxxxx #邮箱登陆密码
4、示例
<?php
echo "hello";
echo htmlspecialchars("<a href='#'>Hi</a>");
$to = "xxx@sohu.com";
$subject = "E-mail From Php Program";
$message = "Hello , This is an E-mail from Php program!";
$from = "hello@sohu.com";
$headers = "From: hello@sohu.com";
mail($to, $subject, $message, $headers);
echo "Mail sent";
?>
页:
[1]