Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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/snydmail.sh

Where snydmail.sh 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

2 Answers 2

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

  :0c:
/path/to/file.txt
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

 
discard

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.