Created
September 23, 2014 06:39
-
-
Save ariunbayar/f56a1c96348eb2d282bc to your computer and use it in GitHub Desktop.
Logs your sent email for PHP.
This file contains 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 | |
/* | |
* Don't forget to set following in your php.ini: | |
* sendmail_path = /path/to/mail_log.php | |
* | |
* You can test with following php code: | |
* mail('user@email.dev', 'subject', 'body'); | |
*/ | |
$mail = ''; | |
$pointer = fopen('php://stdin', 'r'); | |
while ($line = fgets($pointer)) { | |
$mail .= $line; | |
} | |
$title = 'Email at '.date('Y-m-d H:i:s'); | |
$content = "----------------------------\n" | |
.$title."\n" | |
."----------------------------\n" | |
.$mail."\n\n"; | |
$cmd = '/usr/bin/notify-send'; | |
$cmd .= ' ' . escapeshellarg($title); | |
$cmd .= ' ' . escapeshellarg($mail); | |
shell_exec($cmd); | |
file_put_contents('/run/shm/mail.log', $content, FILE_APPEND); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment