Docs/Receive email in a live environment
#

Receive email in a live environment

Give test accounts a mailbox, allow your app's sender domain, and let the agent read codes, links, and invitations during a run.

Receive email in my live environment

Cofactor gives a test user an inbox on testuser.runcofactor.com. Mail your deployed app sends to that address lands there, and the agent that runs your test can read it. This page covers live environments. A sandbox catches your app's email with no setup, see Emulators.

Read your app's email

  1. Ask Cofactor to turn on email. Receiving email on a live environment is turned on for your organization by the Cofactor team. In the app, open Settings, then Email, and select Contact the Cofactor team. Tell them the domain your app sends email from. Cofactor delivers mail only from sender domains it has approved, and drops the rest.

  2. Give the login an inbox. Open Applications, your application, Test Users, then Add credential on a persona. Choose Enter your own credentials.

    • If the username is an address on testuser.runcofactor.com, Cofactor creates the inbox when you save.
    • For any other username, select Provision an email inbox. Cofactor makes an address and pairs it with the credential.

    Your app must send its email to that address. Use it when you sign up or invite the user.

  3. Describe the email in the test. Say what to read and what to do with it, for example "Open the most recent sign-in email and enter the 6-digit code." Don't copy a code or link into the test. It changes every run.

  4. Run the test in the environment. See Test a live environment.

Check it worked

bash
cofactor credential list --application "Acme Web"
cofactor workflow run <test id> --environment staging --stream

The credentials list shows an Email inbox tag on the login. The run reads the email and finishes the sign-in. If nothing arrives, ask the Cofactor team to check that email is on and that your sender domain is approved.

Go deeper