CentOS 5.5下安装完成后主要是遇到了下面错误,记录下来供大家参考:
sh: -t: command not found
我的系统是通过网络最小化安装的,所以有很多命令和小工具以及一些服务都没有安装。
今天抽空安装了一下Sendmail:
1. 查找需要安装包:
[root@ ~]# yum search sendmail
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: centos.mirror.cdnetworks.com
* base: centos.mirror.cdnetworks.com
* extras: centos.mirror.cdnetworks.com
* updates: centos.mirror.cdnetworks.com
======================================================== Matched: sendmail =========================================================
exim.x86_64 : The exim mail transfer agent
php-pear-Mail.noarch : Class that provides multiple interfaces for sending emails
sendmail.x86_64 : A widely used Mail Transport Agent (MTA).
sendmail-cf.x86_64 : The files needed to reconfigure Sendmail.
sendmail-devel.i386 : Extra development include files and development files.
sendmail-devel.x86_64 : Extra development include files and development files.
sendmail-doc.x86_64 : Documentation about the Sendmail Mail Transport Agent program.
spamassassin.x86_64 : Spam filter for email which can be invoked from mail delivery agents.
sysklogd.x86_64 : System logging and kernel message trapping daemons.
2. 我选择性进行了安装:
[root@ ~]# yum install sendmail sendmail-devel sendmail-cf sendmail-doc mailx
#mailx 方便命令行发邮件
3. 安装完成,下面开始测试
3.1 命令行测试:
[root@ ~]# echo "abc" | `mail -s "Submect test" web@`
检查邮件,发送成功。
如果没有收到可以查看/var/log/maillog中数据内容。
3.2 写PHP进行测试
将下面代码保存为mailtest.php:
$message = 'test mail for ';
mail('web@', 'My Subject', $message);
然后执行进行测试:
[root@ ~]# php mailtest.php
#提示错误:
sh: -t: command not found
解决办法配置php.ini, 主要原因是sendmail_path找不到sendmail:
[root@ ~]# vi /usr/local/php/lib/php.ini
[mail function]
SMTP = localhost
smtp_port = 25
sendmail_path = '/usr/sbin/sendmail.sendmail -t -i'
mail.add_x_header = On
mail.log =/tmp/mail.log
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/pspyw.html