What to use for test email addresses

I often come across test email addresses that people have created and I'm alarmed. It's common to see something like yesyes@nonono.com or test@test.com. But beware, these are real domains.

Consider the following example. You are working away on your site and you need to create a test admin user and you use something funky like the above. You do your thing and forget about it. Months later an email gets sent out to all the administrators on your site. And guess what you just sent an email out to a real domain. Someone reads it, comes to your site and uses the password recovery tool to get admin access to your site. Not good.

Now there's a simple solution. Either use only email addresses at your own domain, or use something at example.com, example.org or example.net. These domain names are reserved for use in documentation and are not available for registration. Any email sent to them will essentially fall into a black hole.

On a somewhat related note it's good practice to use the devel module on all of your non-production sites (development, QA, staging, testing etc.) to send all Drupal-generated emails to the watchdog log and not out into the internets.

Craig wrote 51 weeks 1 day ago

I usually create a gmail account to use for testing purposes. It allows me to validate any emails generated and the use of the alias (e.g. mygmail+alias@gmail.com) makes it great to use one gmail account for multiple emails. I just change the alias to reference the username.

Tom Geller wrote 51 weeks 1 day ago

For the curious, here's the text of RFC 2606, in which IANA codifies the use of example.com. It also reserves .test, .example, .invalid, and .localhost as first-level domains for such purposes.

Caleb wrote 51 weeks 1 day ago

Another useful thing one can do if you need to constantly have a unique email address (because Drupal demands this) is to use plus-addressing. Not all email hosts will work with it, but gmail for instance lets people use:

address@gmail.com
address+string1@gmail.com
address+string2@gmail.com
address+string3@gmail.com

All the emails above will go to the original email address (address@gmail.com)

Michael Prasuhn wrote 51 weeks 1 day ago

I've thought about this too, and been surprised to see the addresses used for test accounts. However myself being about as paranoid as possible, I don't even like to use example.com.

In my case I use the domain of the company I am working at (given that it's a small enough company). I.e. say I am working in a web development shop with 5-10 developers, I'll usually try to ask if there is a catchall collection for email (usually not these days, with spam what it is) and then make up fake addresses at that company's domain.

chx wrote 51 weeks 1 day ago

mailinator.com is awesome for this. Check it out.

Steve wrote 51 weeks 1 day ago

One thing that I found out from another Drupal blog post a couple months ago is that you can use one GMail account multiple times by creating alias addresses on the fly.

If your GMail address is example@gmail.com, emails sent to example+user1@gmail.com, example+user2.gmail.com, example+admin@gmail.com will all go to the root example@gmail.com address.

I use it all the time, and it works great.

hunvreus wrote 51 weeks 1 day ago

The main problem is that you may run out of available email addresses, or you may want to reserve some of them for specific uses, since Drupal requires the email address to be unique for each user.

What I usually do is using Gmail plus-addressing feature: if your address is mamba@gmail.com, then mamba+whatever@gmail.com will also be sent to your inbox but will be treated as a separate address. You could insert dots in your address as well. See http://gmailblog.blogspot.com/2008/03/2-hidden-ways-to-get-more-from-you....

Erik wrote 51 weeks 12 hours ago

Another way to do it if you have a gmail address handy is to use a "modified" gmail address. If your address is bobadmin@gmail.com then you can receive email at bobadmin+anything@gmail.com. Google will ignore anything after (and including) the plus sign. But Drupal will still see these as separate emails. It's also handy for setting up an admin and regular user on the same Drupal site with one gmail account.

http://gmailblog.blogspot.com/2008/03/2-hidden-ways-to-get-more-from-you...

I consistently use my gmail "+testing@gmail.com" and have a filter in gmail for those, that way I can also actually make sure that email really does get delivered.

Good point about the documentation, though. You'd still want to use example.tld for anything that you pass around.

Thanks for the info about example.tld!

Contact Us

About Dave Hansen-Lange

Dave Hansen-Lange has been developing websites since 2003 when he needed a web presence for the record label that he founded with several fellow musicians.

Advomatic on Twitter