loin 发表于 2015-9-15 10:42:39

ubuntu下,使用postfix实现php发送mail功能。[转]

1、ubuntu 下安装postfix,执行命令:

  # apt-get install postfix popa3d
  2、在php.ini配置文件上,设置mail函数:
1)打开php.ini配置,下面是我的php.ini路径:
  # vi /home/service/web/config/php/lib/php.ini
  
2)找到:sendmail_path ,将其设置为:
  sendmail_path = /usr/sbin/sendmail -t
  注意:这里需要先到/usr/sbin/ 目录中,确认是否存在sendmail文件。
  3、启动postfix:
  # /etc/init.d/postfix start
  4、重启apache:
  # /etc/init.d/apache2 restart
  5、以上完成。你可以写一个发送email的php文件做测试,如下:
  <?php
$send = mail(’yourEmail@test.com’, ‘My Subject’, ‘The test mail’);
if($send){
echo ‘true’;
}else{
echo ‘false’;
}
?>
以上,运行如果显示true,则,你将会在‘yourEmail@test.com’中收到一封主题为‘My Subject’的email。
页: [1]
查看完整版本: ubuntu下,使用postfix实现php发送mail功能。[转]