0

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?

2 Answers 2

1

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

  :0c:
/path/to/file.txt
3
  • 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, 2011 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, 2011 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, 2011 at 12:16
1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .