Home > php教程 > php手册 > php 里的使用mail()发送邮件详解

php 里的使用mail()发送邮件详解

WBOY
Release: 2016-06-06 20:02:08
Original
1356 people have browsed it

一.修改php.ini a.找到 ;smtp_port = 25,;sendmail_from = you@yourdomain,把前面的;去掉 b.找到;sendmail_path = 更改为 sendmail_path =/usr/sbin/sendmail -t -i (具体情况见一下 三种 sendmail_path 设置与发信方式 ) c.找到;extension=php_openssl.dll

一.修改php.ini

a.找到 ";smtp_port = 25",";sendmail_from = you@yourdomain",把前面的";"去掉

b.找到";sendmail_path =" 更改为 "sendmail_path =/usr/sbin/sendmail -t -i" (具体情况见一下三种 sendmail_path 设置与发信方式)

c.找到";extension=php_openssl.dll"把前面的 ";"去掉




三种 sendmail_path 设置与发信方式

php.ini 里的 sendmail_path 默认设置是

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

,如果之前有安装过其它Mail Server 的话,请清除干净。然后才接着下面的步骤
1.SendMail 方式 :安装好 Sendmail 以后就可以正常使用php的 mail() 发信了,不用怎么特意去设置它。

2.Exim 方式:
安装exim后,接着使用ln -s /usr/sbin/exim /usr/sbin/sendmai 文件连接指令。 php.ini 里面的 sendmail_path = /usr/sbin/sendmail -t -i 不用设置,就可以使用 mail() 发信了。

3.PostFix 方式:安装postfix完成后,修改 php.ini 里面的 sendmail_path ,将其设置为: sendmail_path = /usr/sbin/sendmail.postfix -t

二,启动你的 Mail Server.

1.SendMail 方式: /etc/rc.d/ini.d/sendmail start

2.Exim 方式: /etc/rc.d/ini.d/exim start

3.PostFix 方式: /etc/rc.d/ini.d/postfix start

三,重启你的 Apache

我的是:
/usr/local/apache2/bin/httpd -k restart

如果你是以 RPM 安装或者是FC系统默认安装的,路径是:
/etc/rc.d/ini.d/httpd -restart
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template