Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to capture all mail from a unix server and pipe it to a log file? Or maybe at least all mail from PHP? I know of a trick where in php.ini sendmail is tricked byt this line:

sendmail_path = /Users/ckj/Dropbox/scripts/

Where just looks like this:

cat >> /path/to/file/mails.txt

This works fine on my local MAMP server, but I cannot get it working on my CentOS server.

Has anyone got a more clever way than the hack above?

share|improve this question

Do you have procmail installed? If so, you could use a recipe like the following:

share|improve this answer
I do! I'll give that a try. I never fiddled with procmail, so any newbie-link to configuring would be a big help :) – naxoc Apr 12 '11 at 11:31
Procmail is really useful - try here for a useful link about implementing it. I assume that installing it is as simple as yum install procmail but would normally work on debian instead of centos. – vsltd Apr 12 '11 at 12:10
Cool, thanks. Just to make sure I get it. We are talking about outgoing mail from my development sever. I was maybe a bit unclear about that. – naxoc Apr 12 '11 at 12:16

You should consider procmail. It is well designed to filter mail and send it to various mailboxes, or files. I think it will do exactly what you want and beyond, more elegantly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.