Email and SMS codes
Email codes#
1. Connect your mailboxes#
On chrome://pluralbrowser, in the Mail section, add the IMAP mailboxes your codes arrive in (up to 16). Use an app password, not your normal password. A catch-all domain that forwards every address into one of these mailboxes works well: each row in your CSV can then have its own email.
2. Tell Plural what a code looks like#
Mail rules pull the value you want out of a message — a code, or a link. Add a rule in the Mail section; the line under it shows what it found in your newest message, so you can check it works before you run a script.
3. Read the code in a script#
const code = await t.mailCode({ subject: "verification", waitMs: 120000 });
await t.type("#code", code);t.mailCode waits for a new email (one that arrives after you call it) sent to the row's own email address, and returns the value your rule extracts. Options — all must match:
| option | default | meaning |
|---|---|---|
to | the row's email | the exact address the email was sent to |
subject | — | text in the subject |
contains | — | text in the message |
from | — | text in the sender |
waitMs | 120000 | how long to wait before giving up |
Need the whole email (subject, links, text)? Use t.waitForMail(...) with the same options.
SMS codes#
Call your SMS provider's API from the script with fetch. Most providers have a "latest message for this number" call:
async function smsCode(phone) {
for (let i = 0; i < 40; i++) {
const r = await fetch(`https://YOUR-PROVIDER/api/latest?number=${phone}&key=YOUR_KEY`);
const text = (await r.json()).text || "";
const m = /\b(\d{4,8})\b/.exec(text);
if (m) return m[1];
await new Promise((ok) => setTimeout(ok, 3000));
}
throw new Error("no SMS for " + phone);
}
const sms = await smsCode(t.column("phone"));
await t.type("#sms-code", sms);Adjust the URL and the way the code is read to match your provider.