So you need to test and debug email notification templates while working in your local environment. You still need to verify mail is being sent and inspect the email contents. You might create a few accounts with email addresses you own, which I guess works on a small scale. But let's say you need to test bulk mail delivery, or maybe you're working with a preexisting member list of thousands of accounts. Even though you're working on a local server, the email addresses are real and if you mistakenly trigger a bulk mail function, you're going to end up with some very confused users. Of course you're already bootstrapping your EE setup with the Focus Lab conifg overrides right? We'll be using MailTrap.io to isolate and display sent emails from our dev environment.
This service is just amazing -- I couldn't be more pleased with it. If you're doing a lot of email debugging and testing, I highly recommend it. Here's a description pulled from their FAQ page.
MailTrap is a standardized solution for the problem of e-mail notification testing with those notifications isolation from real users of your app. It allows viewing all of your e-mails online on the Mailtrap site, forwarding them to your normal mailbox, share with a team and more.
This guide is focused on ExpressionEngine setups bootstrapped with the Focus Lab config overrides. If you're using something different to bootstrap EE, you should be able to easily tailor these steps to your unique configuration.
First thing to do is setup a MailTrap.io account. It should only take a minute and it's free!
Next log into your account and create a new test mailbox. You'll get a settings screen similar to this one:
Next open your config folder, and locate config.local.php and add the following lines below the existing web_master_email conifg line. Obviously replace the smtp_username and smtp_password in the config lines below with the ones provided in the mailtrap settings screen.
$env_config['webmaster_email'] = 'email@example.com';
$env_config['mail_protocol'] = 'smtp';
$env_config['smtp_server'] = 'mailtrap.io:2525';
$env_config['smtp_username'] = 'USERNAME FROM MAILTRAP SETTINGS';
$env_config['smtp_password'] = 'PASSWORD FROM MAILTRAP SETTINGS';
You should now be able to send and recevie emails while working locally without worry of confusing or annoying your users. This is definitely moar betterer!
Optionally if you're working with HTML templates and want to test your work on an email client, you can have MailTrap forward incoming emails to a specified email address.
If you're working offline, this solution won't work since you need access to MailTrap.io. For these scenarios, you can try using MockSMTP on the the Mac to achieve similar results. I used this a while back and I do recall having a hard time getting it to work properly with MAMP Pro, but it did work.