18

I need to use a throwaway email address domain in my test scripts. Currently, we are using mailinator but it blocks users after a certain limit of bulk emails is reached.

Is there any other better way of achieving this?

1
  • You could use ahem.email. It will receive stabdard smtp email and provide an easy to use web ui or restful api for consuming the emails.
    – Oren Geva
    Commented Sep 21, 2018 at 22:27

8 Answers 8

28

I have used a trick with gmail where you can append +string on any address. The string I filled in was a Unix Time Stamp.

Original Email Address: [email protected]

Testing Email Address: [email protected]

8
  • 3
    Perfect built-in solution. I've used this as well. Don't have to juggle tons of temporary addresses and passwords. You get all the mail in one inbox, but the system you're testing thinks they're all unique users. Commented Nov 9, 2017 at 18:26
  • 8
    As a side effect, you are also testing that s + in email addresses is allowed. (I've had once a web mailer which interpreted + as space, and thus rejected my mail address.) Commented Nov 9, 2017 at 20:10
  • 3
    That's not specific to gmail, most email providers deliver name+stuff@domain mails to name@domain.
    – Džuris
    Commented Nov 9, 2017 at 22:19
  • 6
    @Wildcard It's actually part of the specification for email, but gmail was (one of) the first providers to actually implement it. Same with periods. [email protected] is the same as [email protected]
    – Rob
    Commented Nov 10, 2017 at 6:24
  • 4
    @Rob Actually, the specification mandates that [email protected] and [email protected] be interpreted as different email addresses. Gmail just decided to give both to the same account holder (nothing prohibits an individual to own more than one email address according to the specification). The + thing was a Gmail invention
    – slebetman
    Commented Nov 10, 2017 at 15:47
4

For manual testing (ie, visually inspecting the emails), you should use a local SMTP server, like Bhavani. I've used Mailcatcher in the past and really enjoyed it.

1
4

Any time you need to test something where the application under test interacts with outside services, you have a couple of choices:

1) Stubbing 2) Use a real service

Then there's a choice between using an internal or external stub or service.

Stubbing is where you build a fake interface, that just does enough for the application under test to be tested. The problem is that for something like SMTP, where you have many, many error conditions and the like, in order to stub properly, you might as well write your own SMTP server. Or you could use one of the many options that come up when you google "stub smtp server."

The second option is using a real SMTP server (or, better, several different SMTP servers). For integration testing, this is the best way to go. This is because standards can be interpreted differently, and you need to make sure that your application works with different interpretations of the standards.

Then you have a choice between managing the service internally, externally for free, or externally for a fee. If you're testing anything you plan to charge for, I would very strongly suggest either hosting the service internally, or externally where you have some sort of contractual agreement with the service. In the case of mailinator, for example, anyone can read mail that has been sent to a given inbox. If your competitors find out that you're using a publicly available, world-readable service to test new products with, there's a chance they will be able to figure out what you're working on.

2

I've handled the scenario with the local smtp server setup with the open source tools like hMailserver. After setting up, you can define your own domains and email ids.

0

I use https://www.guerrillamail.com/inbox it has a selection of domains for you to use which gets over the blocking issue.

0

I don't get why you need throw away email addresses. Can't you just remove the account and re-use the same email address again in your tests?

I would have a look at Mailtrap, they have a service with which you can catch mails send from your servers without sending them to a real inbox somewhere. Also I think you can create mailboxes, receive and check email content and such with their API.

0

There are various online solutions the provide you with unlimited email addresses for testing. We are using Mailosaur with Cypress to test our signup and password reset processes.

0

In addition to @kirbycobes answer:

plus addressing / subaddressing is now also available Exchange Online / Office 356

As of May 2022, plus addressing (also known as subaddressing) is enabled by default in Exchange Online. Subaddressing is an industry-defined way to support dynamic, disposable recipient (not sender) email addresses for mailboxes.

Plus addressing uses the syntax: <local-part>+<tag>@<domain>. For example, [email protected]. The original email address must be valid. The +tag value that you add is arbitrary, although regular character restrictions for SMTP email addresses apply (for example, no spaces).

https://learn.microsoft.com/en-us/exchange/recipients-in-exchange-online/plus-addressing-in-exchange-online

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.