Make Your Own Email Address Generator for Testing

When building an app you often need to run through parts of the system manually to check how functionality works or checking a bug report.

A lot of the time this will require creating a new user account on the system, following the steps that a normal user would need to follow.

Most online accounts require a unique email address. This constraint leaves demo systems full of email addresses like Let’s talk about a great way to generate test email addresses.

The problems with

Using fake email addresses hides issues when your development environment sends the email out.

  • You don’t get to see if the email actually shows in an email client
  • If you use a fake domain and that domain starts being used by someone you could end up sending test emails to a real person
  • When you need to follow a link in an email, for example password resets, you have to look through logs

Using a real email address

Using a real email address bypasses these issues. It has the downside of being a finite resource. We don’t have access to thousands of easy to manage email addresses.

Enter Gmail

Gmail has this wonderful feature to create unique email addresses that link to your main email.

If your main account was then you can create append +tag before the @.

These are all valid email addresses that will all go into the same inbox:


We can use one real account to generate lots of unique emails for our demo systems.

Enter TextExpander

Generating unique email addresses by hand doesn’t scale. This is where TextExpander comes in.

You can use TextExpander to add a custom + to your email address.


There are a few ways we can generate something random.

Random Numbers

TextExpander lets you instantly insert Snippets of text as you type—using a quick search or abbreviation. So, we’ll make a “snippet” to help us make new email addresses very quickly.

By writing a snippet that makes use of the bash variable RANDOM we can generate an email address that will be random enough for our purposes.

  1. Open the TextExpander app and create a new snippet
  2. Set the Content type to Shell Script
  3. Paste the following as the body of your snippet

echo -n "pixel+$"

This will generate:

For a longer post on bash commands you will enjoy How to Instantly Insert Your Most Used Bash Commands.

Note: Bash command Snippets only work on macOS. Below we’ll share a way to do this with JavaScript that works on Android, Chrome, iOS, and Windows.


You can also use date based emails, this will be unique and also let you see at a glance when you created it.

pixel+(Year: 2001)(Month: 01)(Day: 01)(Hour: 01 (00-23))(Minute: 01)(Second: 01)

This will generate:

JavaScript Random Email Generator

TextExpander Snippets support JavaScript for Automation (JXA). While Bash scripting only works on macOS, JavaScript automations work on every platform TextExpander supports. Here’s how to create the random email generator Snippet with JavaScript:

  1. Open the TextExpander app and create a new Snippet
  2. Set the Content type to JavaScript
  3. Paste the following as the body of your Snippet
function generateRandomEmail() {
    var randomNum = Math.floor(Math.random() * 10000); // Generate a random number
    var email = "pixel+" + randomNum + ""; // Concatenate to create email
    return email; // Return the email string

generateRandomEmail(); // Call the function and output the result


Using Gmail and TextExpander, never run into the email problem again when testing the signup flow of your system.

If you’d like to play with the snippets in this post, you can check out our sample bash scripts Public Group.

How are you solving your development issues with TextExpander? Let us know @TextExpander and on Facebook.

Not able to play the video? Click here to watch the video