Last active
December 11, 2015 17:28
-
-
Save schmkr/4634605 to your computer and use it in GitHub Desktop.
Script to catch mails on development machines
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/env php | |
<?php | |
# create a filename for this email | |
list($ms, $time) = explode(' ', microtime()); | |
$filename = '/tmp/'.date('Y-m-d h.i.s,', $time).substr($ms,2,3).'.txt'; | |
# write the email contents to the file | |
$email_contents = fopen('php://stdin', 'r'); | |
$fstat = fstat($email_contents); | |
file_put_contents($filename, $fstat['size']."\n"); | |
file_put_contents($filename, $email_contents, FILE_APPEND); | |
# open up the txt file (using Apple Mail) | |
exec('open -a "/Applications/Google Chrome.app" '.escapeshellarg($filename)); |
And only need to change this in php.ini
sendmail_path = "/usr/local/bin/smtp_catcher"
Or wherever the script is stored.
And don't forget to put the executable flag on the file
is there a trick to get it run with OS X 10.10 and XAMPP 1.8.3-5 ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original is from this blog: http://blogs.bigfish.tv/adam/2009/12/03/setup-a-testing-mail-server-using-php-on-mac-os-x/.
Though this does not open the Mail app, it saves the email as an txt file and opens up Chrome.