I'm in a LAMP environment working on a system that sends out a lot of email notifications. I'd like a way to keep PHP from sending out actual emails in my development environment. Right now, I'm commenting out all of the mail() lines, but this is starting to cause confusion downstream with the QA people because they are removing the commented out lines and pushing them to the testers.
Any simple way disable sendmail in PHP without throwing an error?
You could also set up a small php script like described here to write the mails to var/log/mails
:
#!/usr/bin/php
<?php
$input = file_get_contents('php://stdin');
preg_match('|^To: (.*)|', $input, $matches);
$filename = tempnam('/var/log/mails', $matches[1] . '.');
file_put_contents($filename, $input);
Put the script in /usr/local/bin/sendmail
, make it executable and put the line
sendmail_path = /usr/local/bin/sendmail
in your php.ini
another solution for your problem is to setup your local postfix to local delivery. every email will be send to your local email account!
https://serverfault.com/questions/137591/postifx-disable-local-delivery
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With