Skip to content

Instantly share code, notes, and snippets.

@moritzjacobs
Last active September 4, 2017 09:04
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 moritzjacobs/d31bba28939a9fc7982c to your computer and use it in GitHub Desktop.
Save moritzjacobs/d31bba28939a9fc7982c to your computer and use it in GitHub Desktop.
phpmaillog v3
#!/usr/bin/php
<?php
/*
# phpmaillog
Save emails to your desktop instead of sending them in local dev environments
## Installation:
### For Mac OS X:
- save to `/usr/local/bin/phpmaillog` (no `.php` extension needed)
- `chmod +x /usr/local/bin/phpmaillog`
- edit your `php.ini`:
`sendmail_path = /usr/local/bin/phpmaillog`
- Test in console:
`echo "Subject: Test\nFrom:foo@example.com\n\nWorks like a charm" | phpmaillog`
You should now find a `<Timestamp>-<ID>.eml` file on your Desktop (use quicklook to view)
### Other OS
*/
$now = @date('YmdHis') + 0;
$email_file = '/Users/'.get_current_user().'/Desktop/'.$now.'-'.uniqid().'.eml';
$email_content = '';
$pointer = fopen('php://stdin', 'r');
while ($line = fgets($pointer)) {
$email_content .= $line;
}
file_put_contents($email_file, $email_content);
@moritzjacobs
Copy link
Author

moritzjacobs commented Feb 16, 2015

phpmaillog

Save emails to your desktop instead of sending them in local dev environments

Installation:

For Mac OS X:

  • save to /usr/local/bin/phpmaillog (no .php extension needed)
  • chmod +x /usr/local/bin/phpmaillog
  • edit your php.ini:
    sendmail_path = /usr/local/bin/phpmaillog
  • Test in console:
    echo "Subject: Test\nFrom:foo@example.com\n\nWorks like a charm" | phpmaillog
    You should now find a <Timestamp>-<ID>.eml file on your Desktop (use quicklook to view)

Other OS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment