Windows下面配置sendmail邮件服务器winmail邮件服务器
这两天搞邮件服务器,头大了,不过还是被我搞出来了,初接触,完全靠自己摸索,现在把经验整理一次,供其他同学学习,多多交流。
1、apache服务器里面使用
win10下面WAMP集成环境:Apache/2.4.18 (Win64) PHP/5.6.19 Server at localhost Port 80
php mail()函数在windows不能用,需要安装sendmail ; 1.从下载sendmail.zip
2.解压到wamp任意目录下,例如D:\wamp64\sendmail,最好短路径,长路径名有可能产生问题。 以供php和apache调用。
3.配置sendmail.ini,配置文件就在刚刚解压的那个目录里面,我的目录如下:
需要修改的地方:
smtp_server= //这里写发送邮件的邮件服务器smtp_port=25 //发送邮件服务器端口,默认25,一般不需要修改
error_logfile=error.log
debug_logfile=debug.log
这两个是错误调式,一开始建议打开;
[email protected] //邮箱名称
auth_password=kuaikuaichengzhang //邮箱密码
[email protected]
到这里,sendmail.ini就配置好了
4.配置D:\wamp64\bin\php\php5.6.19\phpForApache.ini
[mail function]; For Win32 only.
SMTP =
smtp_port = 25
; For Win32 only.
sendmail_from = [email protected]
; For Unix only. You may supply arguments as well (default: “sendmail -t -i”).
sendmail_path = “D:\wamp64\sendmail\sendmail.exe -t -i -f”
就配置四项,smtp、smtp_port 、sendmail_from和sendmail_path
好了,这就可以了,
以下是php代码:
// The message
$message = "Line 1\nLine 2\nLine 3";
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send
mail('1037547965@', 'My Subject', $message);
看看,已经发送成功了!大功告成!右键》在此新窗口中打开,可以看到大图:
2、nginx服务器里面使用
下面发一个使用nginx服务器的时候配置sendmail服务器:
需要配置php.ini里面的关于Mail配置那一段;
配置一下sendmail.ini,方法同apache的基本一样。