---
title: "Sendmail 故障解决一例"
author: "AllenZhang"
date: "2012-07-20T15:29:13Z"
tags: ["CentOS", "sendmail"]
categories: ["企业架构"]
slug: "sendmail"
draft: false
lastmod: "2012-09-05T15:47:49Z"
id: 1602185
url: "https://allenzhang.iteye.com/blog/1602185"
---

环境： CentOS 5.4

故障表现：邮件服务器没法对外投递邮件。

故障排查：外部邮件投递使用的是sendmail， 因为未知原因，应用程序无法连接25端口。进一步排查后发现，25端口仅对于ip 127.0.0.1开启。 当使用其他本地ip时，无法连接sendmail.

故障解决：

1\. 修改/etc/mail/sendmail.mc

```
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
```

 修改为：

```
DAEMON_OPTIONS(`Port=smtp,Name=MTA')dnl
```

 

2\.

```
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
```

 

如果出现类似错误：sendmail.mc:10: m4: cannot open \`/usr/share/sendmail-cf/m4/cf.m4': No such file or directory, 可能是sendmail-cf没有安装。

可以通过：

```
yum install sendmail-cf 
```

 解决。

 

3\. 重新启动sendmail:

```
sudo /etc/init.d/sendmail restart
```