I have a LAMP stack set up on a Debian 8 (jessie) machine. I'm trying to find a way of intercepting all outgoing mail sent by PHP (through sendmail) and instead of sending it out, deliver it to my local inbox (to the local user). I don't want to send anything to the outside world, I only want to be able to see the content of a message through my terminal.

I know that this works with Postfix, but I can't install Postfix on my machine because it conflicts with Exim4 and I don't want to make too many changes to my dev. server.

Can this be done and how?

1 Answer 1


You have to create the router that redirect outgoing messages:

  driver          = redirect
  domains         = !+local_domains
  data            = auditor@local.tld
  pipe_transport  = address_pipe

Place that router at the very beginning of begin routers section to ensure each message will be proceeded. When message addressed to the outer domains fall into that router, it will replace original recipient(s) with auditor@local.tld. You can also implement white/black lists of recipients that will be checked by router. Say, if recipient belongs to the white list, then message will not be intercepted while all other will be.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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