Question

I'll try to explain what I want.

I have a PHP script that send emails to different REAL addresses. I don't like these emails goes to Internet, just redirect all of them to my local mail (user@localhost) or simple write emails to local file (with headers for sure).

I'm using Linux on my desktop.

Was it helpful?

Solution

Two options:

  1. Setup Postfix/Courier/Nullmailer/Sendmail/whatever SMTP server you are using to deliver all mail locally. (Hint: https://serverfault.com/questions/144325/how-to-redirect-all-postfix-emails-to-one-external-email-address)
  2. If you want a solution only for PHP, then it would probably be best to create a class or special function in PHP that checks for some constant or variable (eg, 'DEV', or '$debug'), and when that variable is set to true, you send only to the local email address.

(1) May be a good option if you are always and only using this computer for testing purposes, and don't have to worry about accidentally sending out an email to a real person, and (2) is better if you have a specific project you are debugging temporarily.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top