This code is helpful when you're testing functionality locally that involves sending transactional emails and you don't want to deal with any external services or worry about managing different sets of SMTP credentials across environments.
It prevents emails from leaving your environment and instead saves them in wp-content/mail-logs.
I also installed the HTML Preview extension in VS Code so I can easily open the email directly in my editor.
mail-logger.php