Check an email
check_emailChecks the newest matching email at the address (or email_id, from count_emails): SPF, DKIM and DMARC, links to localhost or plain http, where its sign-in, verify, reset or invite link goes (expect_host), whether it says when its sign-in code or link expires and when a coupon ends, a plain-text part, its size against Gmail's 102 KB limit, image-only emails, whether it fits a phone (fixed widths, alt text, tiny text), and, when asked, whether it contains given phrases (expect_text), is in a given language (expect_language) arrived soon enough after since (expect_within, such as 5m) and has the attachments expected (expect_attachment, such as .pdf). A marketing email also gets list_unsubscribe (a List-Unsubscribe header with an https address), one_click_unsubscribe (List-Unsubscribe-Post, covered by a DKIM signature that verified), unsubscribe_link (one in the email), preheader (preview text) and after_unsubscribe (it came after the address unsubscribed from its sender, see mark_unsubscribed); other emails skip them. A coupon also gets offer_reuse: it fails when the sender already sent a coupon to another version of the address (name+promo1@…, capitals); and coupon_result, once record_coupon_result has said what checkout did with it. Marketing email is also judged by the rules where the persona lives (see record_consent): marketing_consent, prechecked_consent, double_opt_in, unsubscribe_deadline, postal_address, sender_identity, minor_marketing, misleading_subject (a fake Re: or a deadline the email contradicts) and ad_label (Singapore's ). Every email also gets harmful_attachment (a file type Gmail blocks, such as .exe or a program named like a .pdf, fails; macros, HTML pages and archives warn) and spam_risk, a spam score out of 10 (score, with the markers that add up to it) of whether inboxes would reject it or file it as spam (5 or more fails), might (1.5 or more warns) or wouldn't (pass). Each check passes, fails, warns or is skipped, with a one-line reason. Verdicts only: never the email's text or links. Wait for the email first. The marketing and coupon checks need Marketing and offer emails, and harmful_attachment and spam_risk need Spam score and attachment checks, switched on in Account settings → Labs; checks of a feature that's off are left out.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| test | No | With run_id: the test or step this call belongs to, shown beside what it saw in the report. | |
| type | No | Only emails with a code, or with a link. | |
| since | No | Only email received at or after this time, such as when the test submitted the form. | |
| run_id | No | A run from start_run: what this call sees is added to its report. | |
| address | Yes | A test address in this project. A variant works too (capitals, or a +tag such as name+o'brien@…): it acts on the plain address, and a wait on a +tag variant only finds mail sent to it. | |
| service | No | Only email from this sender, by service name or domain. | |
| subtype | No | With type, comma-separated: otp or coupon for codes; verify, magic_signin, invite, reset, other, unsubscribe or list_unsubscribe for links; or any (for links, the sign-in kinds and other). | |
| category | No | Only sign-in emails (auth), receipts and notices (transactional), or offers and newsletters (marketing). For "an unsubscribed user gets no marketing", use marketing: receipts should still arrive. | |
| email_id | No | The email to check, as count_emails gives it. Default: the newest that matches. | |
| expect_host | No | The site its links should go to, such as staging.example.com (subdomains count). Without it, that check is skipped. Links to a host marked with mark_dev_host pass the local-links check. | |
| expect_text | No | Phrases the subject or body should contain, such as the user's first name. Case, curly quotes and spacing don't matter. The answer names only the missing ones. | |
| expect_within | No | With since: how soon after it the email should arrive, such as 90s, 5m or 2h (arrival_time). For a coupon after signing up for an offer, say. | |
| expect_language | No | The language it should be in, such as de or pt-BR. | |
| expect_attachment | No | Attachments it should have: a type (application/pdf, image/*), an extension (.ics) or a file name with * (invoice-*.pdf). The answer names only the missing patterns. |