Block reference / Online services

Read email

Wait for an email in a mailbox and take the code, the link or the text out of it.

In both appsWarpX BrowserWarpX Phone

Use Read email after a sign-up or a sign-in that sends a code or a confirmation link: the block opens the account's mailbox over IMAP, waits for the email to arrive, and hands on the six-digit code or the link in it. It finds the newest email that fits your filters, checks again every five seconds until it turns up, and leaves by its fallback output if it never does. It needs the WarpX Browser desktop app.

The Read email block's settings, filled in as in the example below.

Settings

Mail provider

Fills in the IMAP server for you: Gmail, Outlook / Hotmail, Yahoo, Yandex, iCloud, Zoho, GMX, Rambler, or Other (IMAP server) to type it yourself. Choosing Outlook / Hotmail switches the sign-in to a refresh token.

ExampleGmail
IMAP serverwhen Mail provider is Other (IMAP server)

The mail server's IMAP address, such as imap.mail.example.com. Always over TLS.

Exampleimap.example.com
Portwhen Mail provider is Other (IMAP server)

The IMAP port. 993 for almost every server.

Example993
Email address

The mailbox to read, and the user name it signs in with. Usually a reference to the profile's own account, such as {{variables.email}}.

Example{{variables.email}}
Sign in withwhen Mail provider is Outlook / Hotmail

Refresh token (OAuth2) or Password. Microsoft no longer accepts a password over IMAP, so keep the refresh token unless your server says otherwise.

ExampleRefresh token (OAuth2)
Refresh tokenwhen Mail provider is Outlook / Hotmail and Sign in with is Refresh token (OAuth2)

The account's OAuth2 refresh token, the long string starting M.C5… or 0.A…. Accounts bought in bulk usually come as email|password|refresh_token|client_id: this is the third part.

Example{{variables.refreshToken}}
Client IDwhen Mail provider is Outlook / Hotmail and Sign in with is Refresh token (OAuth2)

The app the refresh token was issued to, a GUID. In a bulk line it is the fourth part. A token only works with the client ID it came with.

Example9e5f94bc-e8a4-4e73-b8be-63364c29d753
Passwordwhen the provider signs in with a password (every provider but Outlook / Hotmail, which can choose it under Sign in with)

For Gmail, Yahoo, iCloud and Zoho, an app password, not the account password: those providers refuse the normal one over IMAP. Generate it in the account's security settings (for Gmail, 2-Step Verification must be on). Other providers take the normal password. Keep it in Databases → Credentials.

Example{{secrets.gmailAppPassword}}
From contains

Under Which email. Only emails whose sender contains this, ignoring letter case. Part of an address works, such as shop.example.com. Empty means any sender.

Subject contains

Only emails whose subject contains this, ignoring letter case. Empty means any subject.

Exampleverification code
Body contains

Only emails whose text contains this, ignoring letter case. Useful when one sender sends several kinds of email.

Example
Folders

The folders to look in, separated by commas, in that order. INBOX alone on a new block. A code often lands in spam: that folder is [Gmail]/Spam on an English-language Gmail account and Junk on Outlook. A folder the account does not have is skipped without an error.

ExampleINBOX, [Gmail]/Spam
Received in the last (minutes)

Ignores older emails, so yesterday's code is not typed today. 10 on a new block. 0 means no minute limit, but only about the last day's mail is searched.

Example10
Wait up to (seconds)

How long to keep checking for the email, every five seconds. 60 on a new block, at most 600. 0 checks once.

Example90
Only unread emails

Skips emails already marked as read. Together with Mark the email as read, a code is never used twice.

ExampleUnchecked
Take from it

A code takes the first number of four to eight digits, from the subject first and then the text. A link takes the first link. A regular expression match takes what your expression matches. The whole text takes the email's text. An email that has none of it is passed over, and the block keeps looking.

ExampleA code
Code pattern (optional)when Take from it is A code

A regular expression for the code when the default catches the wrong number, such as an order number. \b(\d{6})\b takes six digits only. The first group in brackets is what you get.

Example\b(\d{6})\b
Link contains (optional)when Take from it is A link

A regular expression the link must match, so the confirmation link is taken rather than the logo's or the unsubscribe link. verify|confirm takes the first link containing either word.

Exampleverify|confirm
Regular expressionwhen Take from it is A regular expression match

Searched in the subject, the text and the HTML, ignoring letter case. The first group in brackets is what you get, or the whole match if there is none. /…/ with flags works too.

ExampleYour PIN: (\w+)
Mark the email as read

Marks the email the value came from as read. On for a new block.

ExampleChecked
Delete the email afterwards

Deletes the email the value came from, so the mailbox does not fill up over many runs.

ExampleUnchecked
Assign to variable

Keeps the value in a variable. On for a new block.

ExampleChecked
Variable namewhen Assign to variable is ticked

The variable that receives the code, the link or the text. emailCode on a new block.

ExampleemailCode
Insert to table

Also writes the value into a column of the workflow's table. Offered only when the workflow has table columns.

ExampleUnchecked
Select columnwhen Insert to table is ticked

The column that receives the value.

Examplecode

Every block also has the shared block settings — a description, Disable block and what to do on an error. Fields that take text accept data from earlier blocks.

What it hands on

When an email turns up, the code, link or text goes to the variable you named ({{variables.emailCode}}), to the table column if you chose one, and on as {{prevBlockData}}. The log line names the email, such as "Your verification code" from Shop <[email protected]>, and the block leaves by its top output. When nothing turns up within Wait up to (seconds), it leaves by its fallback output with No matching email within 90s; with no fallback connected, the run stops with that error.

Example: Sign up, read the code from Gmail and type it

  1. Start
  2. Open URL
  3. Forms
  4. Click element
  5. Read email
  6. Type text
  7. Click element
Where Read email sits in the example workflow.
  1. In the Gmail account, turn on 2-Step Verification, then create an app password at myaccount.google.com/apppasswords. Save it in Databases → Credentials as gmailAppPassword.
  2. Add Open URL with https://shop.example.com/signup, fill the form with Forms using {{variables.email}}, and Click element on Create account.
  3. Add Read email. Leave Mail provider on Gmail, set Email address to {{variables.email}} and Password to {{secrets.gmailAppPassword}}.
  4. Set From contains to [email protected], Subject contains to verification code, and Folders to INBOX, [Gmail]/Spam.
  5. Keep Received in the last (minutes) at 10, set Wait up to (seconds) to 90, and leave Take from it on A code with Code pattern (optional) \b(\d{6})\b.
  6. Add Type text on the code field with Text to type {{variables.emailCode}}, then Click element on Verify.
  7. From the fallback output, add Telegram with No code for {{variables.email}} so you hear about the profiles that got stuck.
  8. Run it. The log shows "Your verification code" from Shop <no-reply@…>, and the code is typed in a few seconds after it arrives.

Good to know

  • Desktop app only. A browser extension cannot open a mailbox, so the block is not offered in the extension's block list, and an imported workflow that has one fails with a message saying so.
  • The mailbox is opened from this computer, not through the profile's proxy. The mail provider sees your own connection, as it does when you read your mail.
  • Outlook and Hotmail: a refresh token stops working if the account's password is changed or the token is unused for about 90 days. The block then fails with Microsoft refused the refresh token: and Microsoft's reason.
  • A wrong password or app password fails with Could not sign in to imap.gmail.com: and the server's reason. That is an error, not the fallback: the fallback is only for an email that never came.
  • Only the 30 newest emails per folder that pass From contains and Subject contains are opened on each check. Tight filters make the block both faster and more accurate.
  • With many profiles sharing one catch-all mailbox, put something unique to the profile in Body contains, such as {{variables.email}}, so each profile takes its own code.

See also

  • Type text — Put text into an input, textarea or editable element.
  • OTP input — Type a one-time code into a row of boxes that take one character each.
  • Get OTP — Work out the current 6-digit two-factor code from its secret.
  • Telegram — Send a message, a picture or both to a Telegram chat, group or channel with your own bot.