程序员反映在sun.xmnn.cn(192.168.96.55)不能利用PHP的mail()函数发送邮件。已解决。

设置步骤如下,

1.启动sendmail服务 /etc/init.d/sendmail start

2.将sendmail服务加入开机启动项 chkconfig sendmail on

3.编辑access文件,加入以下域

vim /etc/mail/access

Connect:xmnn.cn RELAY

4.编辑php-fpm.conf文件,去除sendmail_path键值的注释符号

vim /data/php/etc/php-fpm.conf

<value name=”sendmail_path”>/usr/sbin/sendmail -t -i</value>

5.编辑php.ini文件,设置sendmai_path变量

vim /data/php/etc/php.ini

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

6.该台服务器有设置nameserver。如没有的话,请编辑/etc/resolv.conf

加入以下内容

nameserver 202.101.103.55

nameserver 202.101.103.54

7.另,利用命令行测试系统sendmail是否可用,请参考此文章中“Linux 下使用 telnet 功能”小节。

附部分测试程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php

if ($_SERVER['REQUEST_METHOD']=='POST'){

$email=$_POST['email'];

$to="hery78567650@163.com";

$subject = "Test Mail Send by XMNN.Apps";

$message = "Hello! This is a test sent by php.apps on sunbbs. Poople".$email;

$from = "sun@xmnn.cn";

$headers = "From: $from"."\r\n" .

"CC: 7215030@qq.com";

if (mail($to,$subject,$message,$headers)){

echo "????";

}

}

?>
, ,
Trackback

no comment untill now

Add your comment now