Skip to content

Instantly share code, notes, and snippets.

@perifer
Created March 20, 2009 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perifer/82454 to your computer and use it in GitHub Desktop.
Save perifer/82454 to your computer and use it in GitHub Desktop.
#!/usr/bin/env php
<?php
$dir = "/tmp/phpmails";
if (!is_dir($dir)) {
mkdir($dir);
}
$input = file_get_contents('php://stdin');
preg_match('|^To: (.*)|', $input, $matches);
$filename = isset($matches[1]) ? $matches[1] . '_' : 'no-recepient_';
$t = tempnam($dir, $filename);
file_put_contents($t, $input);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment