A PHP Error was encountered

Severity: Notice

Message: Only variable references should be returned by reference

Filename: core/Common.php

Line Number: 242

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /nfs/c09/h01/mnt/210761/domains/nainteractive.com/ee-sys/codeigniter/system/core/Exceptions.php:170)

Filename: bad-behavior/screener.inc.php

Line Number: 9

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /nfs/c09/h01/mnt/210761/domains/nainteractive.com/ee-sys/codeigniter/system/core/Exceptions.php:170)

Filename: libraries/Functions.php

Line Number: 806

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /nfs/c09/h01/mnt/210761/domains/nainteractive.com/ee-sys/codeigniter/system/core/Exceptions.php:170)

Filename: libraries/Functions.php

Line Number: 806

A PHP Error was encountered

Severity: 8192

Message: Non-static method Switchee::usage() should not be called statically, assuming $this from incompatible context

Filename: switchee/pi.switchee.php

Line Number: 9

A PHP Error was encountered

Severity: 8192

Message: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead

Filename: core/Security.php

Line Number: 483

A PHP Error was encountered

Severity: 8192

Message: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead

Filename: core/Security.php

Line Number: 484

A PHP Error was encountered

Severity: 8192

Message: Non-static method Mx_jumper::usage() should not be called statically, assuming $this from incompatible context

Filename: mx_jumper/pi.mx_jumper.php

Line Number: 21

A PHP Error was encountered

Severity: 8192

Message: Non-static method Na_active::usage() should not be called statically, assuming $this from incompatible context

Filename: na_active/pi.na_active.php

Line Number: 9

A PHP Error was encountered

Severity: 8192

Message: Non-static method Comment::form() should not be called statically, assuming $this from incompatible context

Filename: libraries/Template.php

Line Number: 3006

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /nfs/c09/h01/mnt/210761/domains/nainteractive.com/ee-sys/codeigniter/system/core/Exceptions.php:170)

Filename: core/Common.php

Line Number: 408

Nuno Albuquerque : Notebook - Use MailTrap.io to safely test and debug email while developing with ExpressionEngine

Use MailTrap.io to safely test and debug email while developing with ExpressionEngine

0 Comments Development, ExpressionEngine, Quick Tip

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.

What is MailTrap?

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.

Create an Account

First thing to do is setup a MailTrap.io account. It should only take a minute and it's free!

Create a Mailbox

Next log into your account and create a new test mailbox. You'll get a settings screen similar to this one:

Add the config overrides

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'] = 'you@domain.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!

Going Further

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.

Caveats

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.

 

Discussion 0 Comments

Be the first to add your comment.

Add your comment