CentOS 5.5 + php5.3.3 安装 SendMail

本文详细介绍了在CentOS5.5环境下安装Sendmail的过程,并记录了安装过程中遇到的问题及解决方法。此外,还提供了通过命令行和PHP测试邮件发送功能的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 ~]# echo "abc" | `mail -s "Submect test" web@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 /etc/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 


From: http://www.linuxidc.com/Linux/2011-12/49010.htm


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值