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 Mail.app 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.

2 Answers 2


You can try this:

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

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

/.*/ your@email.com

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

  • 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). Apr 19, 2011 at 9:56

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.