Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

260
Views
How to generate unique random emails with nodemailer

I would like to use nodemailer in a few tests to be able to pragmatically test the contents of an email that is sent. So far, its working great but there is one issue I haven't been able to solve.

I am using the createTestAccount from the Javascript nodemailer, and notice that it often returns me the same test email (I think it uses the same email for a period of time?)

How can I use this to always generate different emails?

I have a condition where I my code fails if the email isn't unique across tests.


As an example, a flow I am testing is:

  1. [behind the scenes a user is created in the database]
  2. User goes to sign in page
  3. User enters email and is asked to enter one time password
  4. User signs into email and gets code
  5. User enters code into website and is successfully signed in

The email with the one time password is sent via an external service so I can't mock it.

For each of my tests there are different configurations so I need a unique user I create in the background for each test. My tests also change the information about the user (in the database). I am also running these tests in parallel so using the same user will result in tests being influenced by other tests.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

After looking the source code of nodemailer I found there is a cache you can disabled by ETHEREAL_CACHE=false. This generates new emails every time.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!