CentOS 5.5 + php5.3.3 install SendMail

2012年11月27日 综合技术 暂无评论 阅读 3,403 次

CentOS 5.5下安装完成后主要是遇到了下面错误,记录下来供大家参考:
sh: -t: command not found


1. 查找需要安装包:

[root@www.linuxidc.com ~]# 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@www.linuxidc.com ~]# yum install sendmail sendmail-devel sendmail-cf sendmail-doc mailx
#mailx 方便命令行发邮件

3. 安装完成,下面开始测试
3.1 命令行测试:

[root@www.linuxidc.com ~]# echo "abc" | `mail -s "Submect test" web@www.linuxidc.com`

3.2 写PHP进行测试

$message = 'test mail for www.linuxidc.com';
mail('web@www.linuxidc.com', 'My Subject', $message);


[root@www.linuxidc.com ~]# php mailtest.php
sh: -t: command not found

解决办法配置php.ini, 主要原因是sendmail_path找不到sendmail:

[root@www.linuxidc.com ~]# 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