37

I would like to write some integration tests which verify if user receive registration confirmation e-mails.

Ideally, for this purpose I would like:

  1. Create temporary e-mail account.
  2. Pass it in registration form.
  3. Check if we receive e-mail.
  4. Delete e-mail account.

Are there any disposable e-mail accounts which provides a simple API? I couldn't find any, but existing ones are fairly easy to parse/make requests (e.g. http://10minutemail.com/).

Is this sounds like a good idea? The alternative is use some gmail account and use tags for this purpose. However, dealing with msgs in spam folder, other folders, etc. sounds a bit more complicated.

Jakozaur
  • 1,957
  • 3
  • 18
  • 20

5 Answers5

82

you can test with your email from Gmail, just append +something to your email address:

myemail@gmail.com

you can have a test account that will deliver to your normal Gmail address:

myemail+testuser1@gmail.com

myemail+testusern@gmail.com

Community
  • 1
  • 1
manuelBetancurt
  • 15,428
  • 33
  • 118
  • 216
  • 7
    why the downvote? try it and let me know if it works :/ – manuelBetancurt Sep 07 '16 at 04:46
  • 2
    This is a valid answer. It's true, just try it and then you will be able to use several email accounts for testing purposes – fablexis Sep 27 '16 at 00:40
  • If the goal is to not reveal your real address, this fails. – tripleee Oct 20 '16 at 10:52
  • 2
    Wow, this is great. I didn't know you can use your email address like that. @tripleee of course you're free to create an extra gmail address just for your testing. No need to reveal your real address. – Bruno Bieri Jul 12 '17 at 08:50
  • 2
    Wow. "+whatEverYouWant@gmail.com" actually sent to my original email. This is amazing!! You are my new hero! – RayLoveless Sep 08 '17 at 18:35
  • 3
    This is great, but many web services do not allow a + in email address for their sign up process. – edencorbin Sep 21 '17 at 15:17
  • It's good suggestion, but it's not good for automated tests. DUe to Gmail can return the following Error: Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 – Roman Podlinov Aug 02 '18 at 11:45
  • Wow this is something! Never heard about this before, thanks! – Robin Carlo Catacutan Oct 16 '18 at 10:34
  • 1
    This does not work for me. I need test accounts for testing my Android app but the accounts must exist in order to log in to Gmail. When I try this, I just get "Couldn't find your Google account" – FractalBob Dec 08 '19 at 08:36
  • 1
    Yep. This works great. Sounds this must be the correct answer for this quest. – Deepak Keynes Dec 20 '19 at 08:04
  • awesome... i didn't know something like this even works... it's just awesome :) –  Mar 31 '21 at 13:47
  • Just in case someone is wondering: This is not working for SSO with Google. As reported above: "Couldn't find your Google account". – gru Apr 22 '22 at 07:09
19

http://mailinator.com supports POP3.

Connect to the server via POP3 with any username and check e-mail.

user1292828
  • 711
  • 5
  • 5
10

I know this question is relatively old, but this fits your purposes quite well:

https://www.guerrillamail.com

  • Disposable email addresses
  • Emails are deleted after 60 minutes
  • Customizable temporary email address dashboard

I use it on the daily while testing emails or for signing up for services that I'll only use once, that require email verification.

I highly recommend it!

ruffrey
  • 6,018
  • 3
  • 23
  • 19
Seagrass
  • 403
  • 3
  • 7
7

You may use special services for QA/QC engineers with API:

More you can read in article http://railsware.com/blog/2012/06/18/remove-qa-headache-while-testing-email-delivery/

ruffrey
  • 6,018
  • 3
  • 23
  • 19
Vitold S.
  • 402
  • 4
  • 13
  • 1
    I'd throw MailHog into the ring as well. I also recommend looking into Docker images of these services. Using Docker makes the setup really easy, and ensures that all you have to do to reset for the next test is recreate the container. And you don't even have to run your application in Docker, you can just run the mail server. – Jonathon Richardson Dec 15 '16 at 22:31
3

If you're running on a linux machine it'll already have an email service running (username@localhost... eg root@localhost) which is kinda perfect for testing emailing scripts.

I don't know why you'd go to the trouble of automating this when it would be better to rather use dependency injection and create a mock-mailing class so you can adequately do integration testing - instead of the last stage of transmitting the email it simply writes the content to a file, a database, or just stays alive in the mock-object long enough it can be tested before it's garbage collected.

Rudu
  • 15,682
  • 4
  • 47
  • 63