ubuntu下,使用postfix实现php发送mail功能
2011-09-08 16:46
609 查看
1、ubuntu 下安装postfix,执行命令:
# apt-get install postfix popa3d
如果不需要pop3服务,把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。
如果要限制外来主机访问smtp服务,修改/etc/postfix/main.cf里的
inet_interfaces=all
为
inet_interfaces=localhost
# apt-get install postfix popa3d
如果不需要pop3服务,把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。
如果要限制外来主机访问smtp服务,修改/etc/postfix/main.cf里的
inet_interfaces=all
为
inet_interfaces=localhost
相关文章推荐
- ubuntu下,使用postfix实现php发送mail功能。[转]
- PHP使用pear实现mail发送功能 windows环境下配置pear
- PHP使用pear实现mail发送功能 windows环境下配置pear
- PHP_thinkphp框架使用PHPMailer实现发送邮件的功能,以及各种问题解析
- PHPMailer使用QQ邮箱实现邮件发送功能
- PHP发送邮件功能实现(使用163邮箱)
- Web_PHP_使用PHPMailer类实现PHP邮件发送功能;
- 使用中国网建实现Java向手机发送短信的功能
- python脚本实现监控apache,并使用mail发送报警
- 记录:使用PHPMailer在ThinkPHP3.2.3上实现发送邮件功能
- php中使用mail()函数发送邮件
- php使用高斯算法实现图片的模糊处理功能示例
- 使用ubuntu安装邮件服务器Postfix发送邮件的过程
- ubuntu安装使用xvfb+CutyCapt实现网页抓图功能
- 使用lua实现php的print_r()函数功能
- Spring中使用 JavaMailSenderImpl来实现邮件的发送
- Zend Framework框架之Zend_Mail实现发送Email邮件验证功能及解决标题乱码的方法
- PHP实现短信宝发送短信验证码功能
- Ajax应用:使用jQuery和PHP实现功能开关效果
- PHP中使用CURL发送get/post请求上传图片批处理功能