RehabCZ

XAMPP | Mail2Disk script

May 16th, 2025
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | Source Code | 0 0
  1. <?php
  2. /**
  3.  * Mail2Disk XAMPP utility for native sendmail function
  4.  *
  5.  *  In php.ini set following:
  6.  *  sendmail_path="C:\xampp\php\php.exe C:\xampp\mailtodisk\mailtodisk.php"
  7.  *              (path to php executable) (path to this script)
  8.  *
  9.  */
  10.  
  11.  
  12. // Absolute path to folder we would like to store our emails in
  13. const MAIL_DIR = 'C:\\XAMPP\\mailtodisk\\';
  14.  
  15. // File extension of recieved email message
  16. const MAIL_EXT = '.eml';
  17.  
  18. $input = file_get_contents('php://stdin');
  19. $filename = MAIL_DIR . 'mail-' . gmdate('Ymd-Hi-s') . MAIL_EXT;
  20. $retry = 0;
  21.  
  22. while(is_file($filename))
  23. {
  24.     $filename = MAIL_DIR . 'mail-' . gmdate('Ymd-Hi-s') . '-' . ++$retry . MAIL_EXT;
  25. }
  26.  
  27. file_put_contents($filename, $input);
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment