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?

naxoc
  • 101
  • 1

2 Answers2

1

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

  :0c:
/path/to/file.txt
vsltd
  • 486
  • 2
  • 2
  • 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](http://www.vglug.info/complete-sendmail-configuration-rhel-4-5-fedora-linux-open-source) 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
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.

sleeves
  • 228
  • 2
  • 7