Skip to content

Fetch Single Mail (Gmail)

Retrieve a single, specific email from Gmail using a message ID or targeted search query, optimized for fast OTP extraction, authentication links, and single-record parsing.


Overview

While Fetch Mail (Gmail) is engineered for processing email collections, Fetch Single Mail (Gmail) is tailored for point-to-point verification where you need exactly one targeted message (e.g., retrieving the latest two-factor authentication code or password reset token).


Configuration Options

OptionTypeDescriptionRequired
Google Service AccountDropdownAuthorized Google account with Gmail permissions.Yes
Enable Max ResultsToggle SwitchRestricts results to a single message (recommended ON).No
Max Results CountNumber InputSet to 1 for single-message workflows.No
Include Spam/TrashToggle SwitchChecks Spam and Trash folders.No
Enable Retry on FailureToggle SwitchRe-attempts execution on transient API connectivity errors.No
Max Retries (Failure)Number InputNumber of network retry attempts.When retry enabled
Retry Until Mail ReceivedToggle SwitchPolls the inbox until the expected email arrives.No
Max Retries (Until Received)Number InputNumber of polling checks before timing out.When polling enabled
TimeoutNumber InputSeconds to pause between polling checks.No
Enable Regex FilterToggle SwitchExtracts targeted tokens or numbers using regex patterns.No
Regular ExpressionText InputRegex query (e.g., \b\d{6}\b).When regex enabled
Regex ReplaceText InputOptional replacement string for matched pattern.No
Remove UNREAD LabelToggle SwitchAutomatically marks email as read upon retrieval.No
Search QueryDefault ValueGmail query syntax to locate the target message.No

Targeted OTP & Verification Workflows

Extracting an automated one-time password during form execution:

  1. Trigger the Code: Form action submits an input triggering an email dispatch from the target website.
  2. Configure Single Fetch:
    • Search Query: from:[email protected] is:unread
    • Retry Until Mail Received: ON
    • Max Retries: 8
    • Timeout: 5 seconds
    • Enable Regex Filter: ON (\b\d{6}\b)
    • Remove UNREAD Label: ON
  3. Execution: The extension polls Gmail until the message arrives, isolates the 6 digits, and passes them directly to the subsequent OTP form field.

Practical Examples

Example 1: Extracting Latest Security Passcode

text
Google Service Account: [email protected]
Enable Max Results: ON
Max Results Count: 1
Retry Until Mail Received: ON
Max Retries (Until Received): 6
Timeout: 5
Enable Regex Filter: ON
Regular Expression: (?<=Your code is )\d{6}
Remove UNREAD Label: ON
Search Query: from:[email protected] is:unread

Example 2: Extracting Account Activation URL

text
Google Service Account: [email protected]
Enable Regex Filter: ON
Regular Expression: https://app\.domain\.com/activate\?key=[A-Za-z0-9]+
Search Query: subject:"Activate your account" newer_than:1d

Best Practices

  • Combine is:unread with newer_than: Always add newer_than:1d or newer_than:1h to ensure outdated historical emails are never matched accidentally.
  • Always Mark as Read: Keep Remove UNREAD Label enabled so subsequent test runs or loop iterations don't re-read past tokens.
  • Use Lookbehind in Regex: Regex lookarounds like (?<=code:\s*)\d{6} allow you to isolate raw numeric tokens cleanly.