Direct mail API for developers and growth teams. Read the docs →

Email to address lookup: turn an email list into mailing addresses for an API mailing

An email to address lookup sends your email list to a data append service. The service checks each email against its own records and, where it finds one, adds the person’s name and postal address. Only part of a list will match, so plan to mail the matched rows and keep emailing everyone else. Mailr doesn’t sell data or match emails to addresses; it prints and mails the addresses you send. In between, you keep the matched rows, drop opt-outs, update older records for moves, check every address and send what passes in batches of up to 1,000.

On this page
  1. How email to address lookup works before an API mailing
  2. Email append or reverse email append: what to ask for before an API mailing
  3. What to send a data append service for an API mailing
  4. Clean the matched email list before an API mailing
  5. Check and send the matched addresses with the API
  6. Email subscribers and opt-outs in an API mailing
  7. Email to address lookup questions from API senders

How email to address lookup works before an API mailing

A data append service keeps records that tie email addresses to people and their postal addresses. You send it a file of emails. It looks each one up and sends the file back with a name, street, city, state and ZIP on the rows it matched. Rows it couldn’t match come back empty.

A row matches only when the service has that email on file with an address. Some services also take a first and last name with each email, because a known name helps them find the right person. A match can also be to the household instead of the person: the service doesn’t find your subscriber but does find someone who lives with them. Ask how the file marks the difference. It decides whose name goes on the card.

emails.csvData append service
emailnameaddressmatch
ada@example.comAda Park2 Elm St, TempeMatched
sam@example.com——No match
lena@example.comLena Ortiz9 Bay Ct, MesaMatched
marco@example.comLena Ortiz9 Bay Ct, MesaHousehold
What comes back. Matched rows gain a name and a postal address; the rest stay empty. The last row matched through someone else in the home, at an address already on the list, so that home gets one card. Emails, names and addresses here are made up.

How much of a list matches depends on the list and the service. We don’t quote match rates here, because any number a service gives is its own claim about its own data. Have it run a sample of your list before you pay for the whole file, and ask whether you pay for every row you send or only for the rows it matches. Some services bill matches only.

Email append or reverse email append: what to ask for before an API mailing

The two names are easy to mix up, and asking for the wrong one gets you the wrong job. An email append starts from names and postal addresses and finds email addresses. Going from emails to postal addresses is a reverse email append. A data append service is any company that fills in missing fields like these on records you already have, so say which direction you want when you ask for a price.

You haveYou wantAsk for
Names and postal addressesEmail addressesEmail append
Email addressesNames and postal addressesReverse email append

What to send a data append service for an API mailing

  • Your own record id on every row, so the results join back to your data.
  • The email address. If you’d rather not send addresses in plain text, ask whether the service takes a hashed email instead.
  • First and last name, if you have them.

Leave everything else out. Order history, notes and payment details don’t help anyone match an email.

What comes back is your file with new columns: the name, the street lines, city, state and ZIP, often with a status that says whether the row matched. Column names differ by service. Map them to your own before the next step; the script below expects line1, line2, city, state and zip.

Clean the matched email list before an API mailing

  1. Keep only the matched rows. A row with no street address can’t be mailed. Those people are still on your email list, so keep emailing them.
  2. Take out opt-outs. Anyone who unsubscribed from your email, or asked you not to contact them, stays off the mail list too.
  3. Mail each household once. Two emails can match the same address, like a couple who both signed up. Dedupe on the normalized address, as in targeted direct mail.
  4. Update older records for moves. An appended address is only as current as the service’s last update. Ask when its data last went through NCOA. If it can’t say, or it was more than 95 days ago, run NCOA on the matched rows yourself. 95 days is the window USPS uses in its Move Update rule for commercial First-Class Mail and USPS Marketing Mail prices.
  5. Check every address. Confirm each one is a real USPS delivery point before you pay to print it. What the check returns, code by code, is in CASS-certified address verification.
Matched rows onlyDrop opt-outs and repeat householdsNCOA for older recordsPOST /v1/addresses/verifyBatches of up to 1,000
From the matched file to the mail. Keep the matched rows, take out opt-outs and repeat households, update older records for moves, check every address, and send what passes in batches of up to 1,000.

Check and send the matched addresses with the API

Mailr checks addresses two ways, at the same price: 7¢ an address on pay as you go.

  • "verify": true on the batch checks every address as part of the send and mails each piece to the standardized address. If any address is undeliverable, the whole batch is rejected with a 422 that names the bad recipients, and nothing is created or charged.
  • POST /v1/addresses/verify checks up to 1,000 addresses on their own and returns each one’s deliverability, the standardized address and a vacant flag. You decide what to mail.

For an appended list, check first. These addresses came from someone else’s records, and with "verify": true one bad row stops the whole batch. The script below drops unmatched rows, opt-outs and repeat households, checks the rest, and mails the deliverable addresses as 6x9 postcards, $0.89 each on pay as you go with printing and postage included (other sizes are on the pricing page). Every field it sends is in the API reference.

# Mail the rows a reverse email append matched. appended.csv is the file the data service sent back. Column names
# differ by service, so map yours to: id, email, name, first_name, line1, line2, city, state, zip (no match = no line1).
# optouts.csv: one email per line, everyone who unsubscribed or asked for no mail. Older records: run NCOA first.
import csv, os, re, requests

API = "https://api.mailr.dev/v1"
H = {"Authorization": f"Bearer {os.environ['MAILR_API_KEY']}"}

with open("optouts.csv", newline="") as f:
    optouts = {row[0].strip().lower() for row in csv.reader(f) if row}

def household(r):  # one card per address, even when two emails matched it
    return re.sub(r"[^a-z0-9]", "", f"{r['line1']}{r['line2']}".lower()) + r["zip"][:5]

rows, seen = [], set()
with open("appended.csv", newline="") as f:
    for r in csv.DictReader(f):
        if not r["line1"].strip() or r["email"].strip().lower() in optouts or household(r) in seen:
            continue  # no match, opted out, or a household already on the list
        seen.add(household(r))
        rows.append(r)

send = []
for start in range(0, len(rows), 1000):  # one check takes up to 1,000 addresses
    chunk = rows[start:start + 1000]
    res = requests.post(f"{API}/addresses/verify", headers=H, timeout=60, json={"addresses": [
        {"name": r["name"][:40], "line1": r["line1"], "line2": r["line2"] or None,
         "city": r["city"], "state": r["state"], "zip": r["zip"]} for r in chunk]})
    res.raise_for_status()
    for r, v in zip(chunk, res.json()["data"]):
        if v["deliverability"] == "deliverable" and not v["vacant"]:  # the rest: keep emailing them
            send.append({"to": {**v["address"], "name": r["name"][:40]},
                         "merge": {"first_name": (r["first_name"] or "friend")[:14]}})

print(len(rows), "matched,", len(send), "to mail")
for n, start in enumerate(range(0, len(send), 1000)):
    b = requests.post(f"{API}/batches", headers={**H, "Idempotency-Key": f"email-list-mailing-{n}"}, timeout=60, json={
        "kind": "postcard", "size": "6x9",
        "front": open("mail/front.html").read(), "back": open("mail/back.html").read(),
        "recipients": send[start:start + 1000], "description": f"Email list mailing, part {n + 1}"})
    b.raise_for_status()
    print(b.json()["id"], b.json()["count"], b.json()["price"])
Run it with an mlr_test_ key first. The address check is a free simulation (any address with “undeliverable” in its first or second line fails), the batches are checked and priced, and nothing prints or charges.

The batches carry the standardized addresses the check returned, so they don’t pay for a second check. Each one also sends an Idempotency-Key: if the script retries a request within 24 hours, Mailr returns the first batch instead of mailing it twice.

Email subscribers and opt-outs in an API mailing

People who gave you their email already know who you are. A card is one more way to reach them, and it can sound like your emails do, down to their first name and the thing they signed up for. The fields worth changing per card are in personalized direct mail, and ready-made designs are in the templates.

Some habits that help. This is practical advice, not legal advice:

  • Mail people who signed up with you or bought from you, not a file of emails someone else collected.
  • Keep one opt-out list for email and mail, and check it before every send, as the script does with optouts.csv.
  • Give people a way to stop the mail. Put a line on the card, such as a link to your mail preferences, and add whoever uses it to the opt-out list.
  • Put your name and logo up front. Someone who knows your emails may not recognize your postcard.
  • Read the data service’s terms for what you may do with the addresses it returns, and for how long.

Email to address lookup questions from API senders

Does Mailr match emails to mailing addresses?

No. Mailr doesn't sell data or match emails. A data append service does the match; you send the matched addresses to Mailr, which can check each one and then prints and mails the pieces.

What is a reverse email append?

Matching email addresses to names and postal addresses. A plain email append goes the other way: it adds email addresses to a list of names and postal addresses.

How many of my emails will match?

That depends on your list and on the service, and any rate a service quotes is its own claim. Have it run a sample of your list first, then count the matched rows that pass an address check.

Do appended addresses need NCOA?

If the service's records weren't updated for moves in the last 95 days, yes, the same as any other list. Ask the service when it last ran NCOA; if it can't say, run it yourself.

What does mailing the matched list cost?

The lookup is the data service's price. On Mailr, an address check is 7¢ and a 6x9 postcard is $0.89 on pay as you go, printing and USPS postage included. Test keys cost nothing.

START SENDING

Put your first postcard in the mail

Create a key, send a test to yourself, and check the proof before anything prints.

Start sending
  • Postcards, flats and folded mailers
  • A proof before anything prints
  • Free test mode: nothing prints, nothing charges
  • A status for every piece

Free price sheet

Get the price sheet by email

Every postcard, letter, mailer and print product on every plan, with postage included.

We’ll email you the price sheet. By continuing you agree to the Terms and Privacy Policy.

Download the template kit?

mailr-kit.zip · about 310 KB · 59 text files

Only HTML, JSON and Markdown files. No programs, scripts or macros, nothing that installs or runs.