这几天在做网站找回密码的时候,用到了邮件发送,选取了sendmail+phpMailer的组合,windows下面的配置,需要配置sendmail.ini 和php.ini。如果本地没有sendmail先下载。

php.ini 配置:

SMTP = smtp.sina.com.cn

smtp_port = 25

sendmail_path ="C:\php\sendmail\sendmail.exe -t"

“C:\php\sendmail\sendmail.exe -t”这个是sendmail的路径

网上说这个路径尽量要短,我也没有去验证。

sendmail.ini 配置:

smtp_server=smtp.sina.com.cn

smtp_port=25

这俩个是要求验证的时候的账号,密码

auth_username=ifbs
auth_password=XXXX

force_sender=ifbs@sina.com 这个没有什么作用。

对了还有socket的扩展也要开启。。。在php.ini里面。

然后在项目里面使用就可以了。

linux:

配置就和网上说的一样。

我的安装配置是这样的:
1、安装sendmail软件包
2、安装IMAP4软件包
3、编辑/etc/mail/sendmail.mc
//前边省略
dnl This changes sendmail to only listen on the loopback device 127.0.0.1
dnl and not on any other network devices. Comment this out if you want
dnl to accept email over the network.
dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl 注释掉 可用别的机子发信
dnl We strongly recommend to comment this one out if you want to protect
dnl yourself from spam. However, the laptop and users on computers that do
dnl not have 24x7 DNS do need this.
dnl FEATURE(`accept_unresolvable_domains')dnl注释掉 可用IP形式
DAEMON_OPTIONS(`Port=25,Name=MTA')dnl添加
DAEMON_OPTIONS(`Port=587,Name=MSA,M=Ea')dnl添加
dnl FEATURE(`relay_based_on_MX')dnl
MAILER(smtp)dnl
MAILER(procmail)dnl

4、编译/etc/mail/sendmail.mc
#m4 /etc/mail/sendmail.mc > /etc/sendmail.cf
5、编辑/etc/sendmail.cf
Cwlocalhost Qin 202.112.105.172 改这一行
6、编辑/etc/mail/.access
# Check the /usr/share/doc/sendmail-8.11.2/README.cf file for a description
# of the format of this file. (search for access_db in that file)
# The /usr/share/doc/sendmail-8.11.2/README.cf is part of the sendmail-doc
# package.
#
# by default we allow relaying from localhost...
localhost.localdomainRELAY
localhostRELAY
202.112.105.172RELAY
202.112.105RELAY

7、编辑/etc/xinetd.d/.imap .ipop3 最后一行 disable= no
8、重启/etc/rc.d/init.d/.xinetd
9、启动sendmail /etc/rc.d/init.d/sendmail start
10、OK!

推荐链接:http://www.5dmail.net/html/2009-8-18/200981812958.htm

记得如果你是所有的扩展或者是apache mysql 是yum安装的,适合样做,如果是tar.gz安装的,需要查看其他的资料。

就现在情况,yum install sendmail 如果没有的话,就安装下,通过phpinfo看下,socket是否开启。

然后按照推荐的帖子查看配置过程,其实没有几步。好多事没有用的,如果是yum安装的,/etc/mail/sendmail.mc

文件下,只是改一点。

当然在php.ini下,记得只需要配置一个路径  不用像在win下配置username passwd

sendmail_path = /usr/sbin/sendmail -t -i  。

当然如果有人说是用php自带的mail()函数也是可以发的,但是现在的smtp协议就是存储,转发,相信大家都发现了,我这个是sina的自己的邮箱往外发送。

首先是需要获得sina邮箱的验证的。所以必须得通过验证。

最腻歪的如果是你使用自己的linux系统,不是公司的。我使用的是

Fedora13  selinux报错,可是我都根本看不到,总是显示连接失败。

知道本地装了一个虚拟机,才发现错误。

http://www.51testing.com/?uid-225738-action-viewspace-itemid-239851这个是原帖子

解决方法:
1. 关掉SELinux,并重启系统让其生效。
    修改/etc/selinux/config配置文件,设置SELINUX=disabled
    如果不想重启系统,使用命令:setenforce 0
    (也可在grub.conf修改kernel启动参数,添加selinux=0。当然需要重启系统)
2. 或者,修改SELinux的设置,让apache进程可以访问了我的目录。

命令为:chcon –t var_t /home/repo;       chcon –R –t httpd_sys_content_t pub
当我们把SELinux的权限问题解决后,重启了Apache,就一切正常了,我的GitWeb就可以正常运行了。
我们在局域网中使用,网络环境相对安全,所以实际
测试过程中一般都disable SELinux的。当然,为了安全也是可以开启的。




如果还是不行的话,请联系我qq:303956405 大家相互学习 需要要源码的请联系我,呵呵,都是菜鸟。。。。。

posted on 2011-08-15 20:07  xiaokun  阅读(1429)  评论(1编辑  收藏  举报