2014-08-07 13:41:23
来 源
中存储网
邮件服务器
CentOS 5.5下安装是通过网络最小化安装的,所以有很多命令和小工具以及一些服务都没有安装。 今天抽空安装了一下Sendmail:1. 查找需要安装包:[root@www.linuxidc.com ~]# yum search sendmail。

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

我的系统是通过网络最小化安装的,所以有很多命令和小工具以及一些服务都没有安装。

今天抽空安装了一下Sendmail:
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 ~]

检查邮件,发送成功。
如果没有收到可以查看/var/log/maillog中数据内容。
3.2 写PHP进行测试
将下面代码保存为mailtest.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 

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。