WINDOWS7系统中的PHP环境使用sendmail插件和mail()发送
日期:2014-07-13 / 人气: / 来源:网络
win7系统不再自带smtp设置,因此用php的mail函数就必须利用第三方的软件发送,此处介绍sendmail插件。(本章以下内容为转载)
1.从http://glob.com.au/sendmail/下载sendmail.zip
2.解压到C:下,例如C:PHPsendmail,最好短路径,长路径名有可能产生问题。
3.修改php.ini如下
sendmail_path = "C:PHPsendmailsendmail.exe -t"
4.根据你自己的配置环境修改sendmail.ini。
第一次最好启用debug.log_file,error_logfile,以查看sendmail是否生效。
5.重启apache
用sendmail结合其它的smtp服务器,如smtp.gmail.com来实现发邮件。现在大部分邮箱都要求smtp验证,所以要在sendmail.ini中加入用户名和密码。
php.ini配置 (以用gmail邮箱为例)
[mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 465(默认是25,需要改为465)
; For Win32 only.
sendmail_from = zmacro@gmail.com
; For Unix only. You may supply arguments as well (default: “sendmail -t -i”).
sendmail_path = “C:PHPsendmailsendmail.exe -t”
就配置三项,smtp、smtp_port和sendmail_path
sendmail.ini配置
[sendmail]
; you must change mail.mydomain.com to your smtp server
smtp_server=smtp.gmail.com
smtp_port=465(默认是25,需要改为465)
auth_username=yourusername
auth_password=yourpassword
force_sender=zmacro@gmail.com
; default_domain=mydomain.com
sendmail网上有下的,如果你是用xampp,那里面直接就带了。
同时在虚拟主机的httpd.conf里加上这样一句
<directory d:/www/users/username>
php_admin_value sendmail_path "C:PHPsendmailsendmail.exe -t zmacro@gmail.com"(此处记得用双引号,单引号将导致apache不能启动。)
</directory>
此邮件地址为用户的邮件地址,随便添。
------------------------
测试文件mail_test.php
<?
if(mail("yourname@sina.com","测试","测试邮件"))
{
echo "发送成功!!";
}
else{
echo "发送失败!!";
}
?>
如何使用sendmail命令发送带附件的邮件
导读:sendmail发附件需要用uuencode命令这个命令在sharutils组件中,可以远程安装apt-get install sharutilsyum install sharutils服务器上用sendmail发送email很关键的一条是/etc/mail
MySQL数据库,
作者:管理员
推荐内容 Recommended
- 江苏飞浩信息科技期待您的加入07-20
- 江苏飞浩科技欢迎您07-19
相关内容 Related
- 江苏飞浩信息科技期待您的加入07-20
- 江苏飞浩科技欢迎您07-19