3

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?

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
2

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.

0

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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