An easy way to test emails in Magento 2 is just add the following lines
echo $content;
exit();
into the vendor/magento/framework/Mail/Template/TransportBuilder.php
file.
Navigate to the file above and scroll to the line 380
. It should be
$content = $template->processTemplate();
inside prepareMessage()
method.
And add the lines
echo $content;
exit();
after line 380
.
The code should look like this:
protected function prepareMessage()
{
$template = $this->getTemplate();
$content = $template->processTemplate();
echo $content;
exit();
switch ($template->getType()) {
...
Now you can test emails in Magento website.
For example, you can create customer account and when Magento will execute the controller to send “Welcome to the Store …” email you will get the email response on the page.
It will look like this