Created
September 29, 2016 14:35
-
-
Save forsvunnet/eba15688179f6d2a399c2eba33a9bb88 to your computer and use it in GitHub Desktop.
phpsendmail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
date_default_timezone_set('CET'); | |
/** | |
* This script is a sendmail wrapper for php to log calls of the php mail() function. | |
*/ | |
//* Get the email content | |
$logline = ''; | |
$pointer = fopen('php://stdin', 'r'); | |
$mail = ''; | |
while ($line = fgets($pointer)) { | |
if(preg_match('/^to:/i', $line) || preg_match('/^from:/i', $line)) { | |
$logline .= trim($line).' '; | |
} | |
$mail .= $line; | |
} | |
$mail = quoted_printable_decode( $mail ); | |
$id = date( 'Y-m-d_H:i:s') .'_'. uniqid(); | |
//* Write the log | |
file_put_contents('/vagrant/mail/'. $id .'.html', $mail); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment