sendmail 的 clientmqueue 和 mqueue 目录

这篇文章很清楚的描述了这两个目录的区别,实际上 MSP 是由 文件来控制的,当邮件送到外部邮箱 的时候,我们可以不启动本地的 sendmail 服务,系统会直接和收件人的 MX 服务器的 25 端口协商。但是如果我们发送邮件到本地帐号例如 root 或者 userabc 的时候,如果本地的 sendmail 没有启动的话,邮件就堆积在 clientmqueue 里,一旦启动 sendmail 则会把它们发送到 mqueue 里,然后发送到 local account 的邮件会写入 /var/mail/userabc 的邮件文件里,当 userabc 登录系统的时候,会看到 “You have new mail”? 的提示。

用户可以自己 touch $HOME/.forward 文件把本地文件转发到自己外部的邮箱,系统管理员也可以通过修改 aliases 文件,来重定向本地用户的邮件。

When submitting mail by using sendmail as a mail submission program, sendmail copies all messages to “/var/spool/clientmqueue” first. Sendmail is a setgid smmsp program and thus gives any user the permission to do so (/var/spool/clientmqueue belongs to user and group smmsp). Later, another sendmail process, the sendmail mail transfer agent (MTA) copies the messages from /var/spool/clientmqueue to /var/spool/mqueue and sends them to their destination.

/var/spool/clientmqueue is thus the holding area used by the MSP (Mail Submission Protocol) sendmail instance before it injects the messages into the main MTA (Mail Transport Agent) sendmail instance.

Sendmail will save the message in /var/spool/clientmqueue for safe keeping before trying to connect to the MTA to get the message delivered. Normally there would be a ‘queue runner’ MSP sendmail instance which every half hour would retry sending any message that couldn’t be sent immediately. Each message will generate a ‘df’ (message routing info) and ‘qf’ (message headers and body) file. You can list out all of the messages and their status by:

# mailq -v -Ac

When files accumulate in /var/spool/clientmqueue, this is probably due to sendmail localhost MTA not running, and thus the mails don’t get send.

Reblog this post [with Zemanta]