Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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'm developing a webshop. When a order has been placed it sends out invoices and notifications to coworkers via email. Developing anything related to the emails has become really annoying, as I have to change a lot of code during development to avoid sending my coworkers random mails.

I'm using PHP's mail function with the sendmail backend. What I would like to do is configure sendmail to send all mails to my own account instead of the actual addressee. That way I wouldn't have to change any code when I move to production where sendmail is configured differently.

In short: Is there a simple way to redirect outgoing emails during development?

share|improve this question

migrated from Nov 15 '11 at 15:53

This question came from our site for professional and enthusiast programmers.

Sounds like a sendmail question, which is off-topic for this site. Perhaps ? – George Cummins Nov 15 '11 at 15:33
Probably a sendmail question yeah, though I'm interested how other developers test sending emails. I would install anything that solves this easily too. – Jochen Ritzel Nov 15 '11 at 15:37
I define email addresses as a configuration item and maintain different configurations for development and production environments. – George Cummins Nov 15 '11 at 15:39
possible duplicate of How to make sendmail to relay local mails? – mailq Nov 15 '11 at 22:13

Proper way: tune your sendmail.

Fun way: all your php script does is sending mail text and headers to bash script or binary set in php.ini sendmail_path. You can put there your own script, which will do with you mail whatever you want.

Or you can put nothing to sendmail_path and set some mail.log. You will see, that scripts use mail properly, but mail won't actualy work.

share|improve this answer

Append at your

R$+ < @ $=w . > $*     username < @ >

The two sides of the expression are not separated by many spaces but by a TAB

share|improve this answer

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.