Skip to content

Instantly share code, notes, and snippets.

@adis-io
Forked from ScreamingDev/sendmail
Last active August 29, 2015 14:12
Show Gist options
  • Save adis-io/f75d3441936857cd36aa to your computer and use it in GitHub Desktop.
Save adis-io/f75d3441936857cd36aa to your computer and use it in GitHub Desktop.
#!/usr/bin/php
<?php
$input = file_get_contents('php://stdin');
preg_match('|^To: (.*)|', $input, $matches);
$filename = tempnam('/var/log/mail', date('ymd-his-') . $matches[1] . '.');
file_put_contents($filename, $input);
vi /usr/local/bin/sendmail
# copy the above code in it
chmod 755 /usr/local/bin/sendmail
# it doesn't need to be "/var/log/mail"
# it can be any folder you like
# just change it in the sendmail-code above and here
mkdir -p /var/log/mail
chmod 777 /var/log/mail
# in php.ini change the sendmail_path
# which can also be done via .htaccess
sendmail_path = /usr/local/bin/sendmail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment