Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 stackoverflow.com 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 unix.stackexchange.com ? –  George Cummins Nov 15 '11 at 15:33
1  
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
add comment

2 Answers

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
add comment

Append at your sendmail.mc:

LOCAL_RULE_2
R$+ < @ $=w . > $*     username < @ example.com. >

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

share|improve this answer
add comment

Your Answer

 
discard

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.