Skip to content

Instantly share code, notes, and snippets.

@Koc
Forked from anonymous/gist:5803875
Last active December 18, 2015 16:39
Show Gist options
  • Save Koc/5812828 to your computer and use it in GitHub Desktop.
Save Koc/5812828 to your computer and use it in GitHub Desktop.
/usr/local/bin/fake-sendmail
#!/usr/bin/php
<?php
$processUser = posix_getpwuid(posix_geteuid());
$name = $processUser['dir'].'/mail/'.date('Y-m-d H:i:s').'-'.microtime(true).'.eml';
if (!is_dir($dir = dirname($name))) {
mkdir($dir, 0777, true);
}
$fh = fopen($name, "w");
if (!$fh) {
die(1);
}
while ($buf = fread(STDIN, 8192)) {
fwrite($fh, $buf);
}
fclose($fh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment