CentOS 6.5 安装 Sendmail

Sendmail 是一款广泛使用的邮件传输代理(MTA)软件,它能够处理电子邮件的发送、接收和转发,在 CentOS 6.5 系统中安装 Sendmail,可以方便地搭建一个基础的邮件服务器,本文将详细介绍在 CentOS 6.5 上安装 Sendmail 的步骤。
安装前准备
确保系统已更新至最新状态:
sudo yum update
安装必要的依赖包:
sudo yum install -y gcc make autoconf libtool pam openssl openssl-devel
安装 Sendmail
下载 Sendmail 源码:
wget http://ftp.sendmail.org/sendmail/cvs/src/sendmail-8.14.7.tar.gz
解压源码包:

tar -zxf sendmail-8.14.7.tar.gz cd sendmail-8.14.7
配置 Sendmail:
./configure --prefix=/usr/local/sendmail --with-mysql=/usr --with-pgsql=/usr --with-ssl=/usr --with-pam --with-mailbase=/var/spool/mqueue --with-mysql-config=/usr/bin/mysql_config --with-pgsql-config=/usr/bin/pgsql_config
编译和安装 Sendmail:
make sudo make install
配置 Sendmail:
sudo /usr/local/sendmail/bin/m4 /usr/local/sendmail/cf/m4/cf.m4 /usr/local/sendmail/cf/m4/base.m4 > /etc/sendmail.cf
启动 Sendmail 服务:
sudo /usr/local/sendmail/bin/sendmail -bd -q1h
配置 Sendmail
- 编辑
/etc/sendmail.cf文件,配置 Sendmail 的邮件地址和域名:
oLocalHost Name = localhost oLocalDomain Name = example.com oMyhostname = mail.example.com oMydestination = $j @localhost, $j @example.com
- 修改
/etc/hosts文件,添加 Sendmail 的主机名和 IP 地址:
0.0.1 localhost 192.168.1.100 mail.example.com
- 修改
/etc/hosts.allow和/etc/hosts.deny文件,允许本地主机访问 Sendmail:
# hosts.allow ALL : ALL # hosts.deny ALL : ALL
相关问答 FAQs
问题:安装 Sendmail 时出现错误,提示找不到某些库文件?

解答: 请确保已安装所有必要的依赖包,可以使用以下命令检查:
yum list installed | grep -E 'openssl|openssl-devel|pam|gcc|make|autoconf|libtool'
如果发现某些依赖包未安装,请使用
yum install命令进行安装。问题:Sendmail 无法发送邮件,提示“554 5.7.1 Unable to relay for yourdomain.com”错误?
解答: 请检查
/etc/sendmail.cf文件中的oMydestination和oRelayDomain配置项是否正确,确保您的域名与配置项中的域名一致,Sendmail 允许发送到该域名,如果问题依旧,请检查您的网络连接和 DNS 配置。

