16

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?

  • 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 Sep 21 '18 at 22:27
26

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: yourName@gmail.com

Testing Email Address: yourName+1510250387@gmail.com

  • 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. – maxathousand Nov 9 '17 at 18:26
  • 7
    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.) – Paŭlo Ebermann Nov 9 '17 at 20:10
  • 3
    That's not specific to gmail, most email providers deliver name+stuff@domain mails to name@domain. – Džuris Nov 9 '17 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. te.st@com.com is the same as test@com.com – Rob Nov 10 '17 at 6:24
  • 4
    @Rob Actually, the specification mandates that a@b.com and a+a@b.com 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 Nov 10 '17 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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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