Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I currently have php running on my desktop (OS X 10.6.7) with the ability to send emails via the mail() function by having set "relayhost" in /etc/postfix to my ISP as well having as an entry in /etc/postfix/relay_password.

What I would like to have happen (since this is a development computer) is for all emails sent via PHP's mail() function to be delivered to only one external address (so that it then shows up in my inbox).

In /usr/local/lib/php.ini I have tried setting "sendmail_path = sendmail -i $email", but it is still delivered to the address specified in the call to mail() within the php script.

I have seen How to redirect all outgoing email from postfix to a single address for testing, but this did not help me.

share|improve this question
up vote 2 down vote accepted

You can try this:

recipient_canonical_maps = pcre:/etc/postfix/recipient_canonical.pcre

Then put a catch-all in /etc/postfix/recipient_canonical.pcre:

share|improve this answer
This is exactly what I need, thanks! – Matthew Peltzer Apr 19 '11 at 9:55

Write a wrapper for the sendmail executable or its currently-used equivalent that rewrites the destination, and put the script path in sendmail_path.

share|improve this answer
Tried this, could never get my wrapper script to do anything useful, which is no one's fault but mine. I'll keep this in mind if I need more flexibility than Cakemox's answer (such as preserving the original recipient as a header, or appended to the subject or something). – Matthew Peltzer Apr 19 '11 at 9:56

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.