Skip to content

Instantly share code, notes, and snippets.

@tomasfejfar
Last active December 1, 2022 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tomasfejfar/0f73e9b5443960b79e55588b38a9ad31 to your computer and use it in GitHub Desktop.
Save tomasfejfar/0f73e9b5443960b79e55588b38a9ad31 to your computer and use it in GitHub Desktop.
Windows fake sendmail to save mail to file
@echo off
::where do we store the messages
SET mailpath=c:\xampp\tmp\mail\
if not exist %mailpath% mkdir %mailpath%
::create filename
echo %date:~0,11%
SET filename=%date:~11,4%-%date:~7,2%-%date:~3,2%_%hours%-%time:~3,2%-%time:~6,2%_%time:~9,2%
::make filename unique
:random
SET file="%mailpath%%filename%--%RANDOM%.mhtml"
IF EXIST %file% goto :random
::save email to file
more %1 > %file%
echo "%file%" > c:\temp\list
::open email directory with explorer (optional)
start %mailpath%
::or open email file directly
:: start %file%
echo "mail sent"
@tomasfejfar
Copy link
Author

Use like this:

# php.ini
sendmail_path = "c:\xampp-php7\sendmail.bat"

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