2301 words
12 minutes

Resend Email Sending from 0 to Launch: Domain Verification, Sending Relay, and Bounce Monitoring

Resend Email Sending from 0 to Launch: Domain Verification, Sending Relay, and Bounce Monitoring

Scope: You have your own domain, DNS is hosted on Cloudflare, and you want your servers, scripts, and login systems to send notifications from a domain email address. This only covers sending; receiving is in the previous post “Cloudflare Email Routing + Workers: Building a Free Domain Email”. Together the two posts form a complete domain send-and-receive setup.

About this article: Based on my actual migration in October 2026; the code is a trimmed-down version of what's running in production. The domain is written uniformly as example.com, and keys, mailboxes, and servers have all been redacted. For quotas and rules, refer to the official Resend documentation; links are included (verified 2026-11-16).

1. Why Switch

Previously my server notifications (quota alerts, bot notifications) went through a small self-written API layer backed by QQ Mail SMTP. It worked, but there were two problems: the sender was a personal QQ mailbox, which didn't look like a proper notification; and receiving, sending, and reading verification codes were all tied to one mailbox, so if that mailbox ever had a problem, every service would go down together.

What I wanted was: send from my own domain, have an HTTP API, and have a free quota sufficient for personal use. I ended up choosing Resend. According to the official quota documentation, the transactional email quota for a free account is:

Item Free quota
Per day 100 emails
Per month 3,000 emails
Verified domains 3
Rate 10 requests per second (counted per team, not per key)

At the time, among my three servers, only one quota-alert service was actually sending email—a few messages a day—so this was more than enough.

2. Account: Don't Sign Up with Google

I actually had a Resend account as early as May, registered by clicking "Continue with Google." This time I wanted to log in with email and password, so I clicked reset password, and the email never arrived. The reason is simple: accounts created with Google don't have a password in the first place, so no reset email is sent.

In the end, I just registered a new account directly with email + password. From then on, for all sites I've uniformly avoided third-party login, so I can control the account and password myself.

3. Choosing a Sending Domain

I have several domains and agonized over three of them:

  • One is .cn, already used with Cloudflare for receiving email;
  • One is the .com blog domain, whose MX still points to a business email service I've already unsubscribed from—if I used it for sending, replies would bounce;
  • One is a newly registered .dev with no email history at all, clean, but new domains have no reputation.

In the end I chose that newly registered domain, with the sender as noreply@example.com. The reason is that it shares the same brand as the content being sent (a news digest), and it has no old MX records, so nothing else would be affected.

4. Domain Verification: DKIM, SPF, and DMARC

After adding the domain in the Resend dashboard under Domains → Add Domain, it gives you the DNS records to add. Since DNS is on Cloudflare, I used Resend's automatic Cloudflare configuration, which added:

Purpose Record
DKIM signing One DKIM record
SPF / bounce return path Two CNAMEs starting with send and rsend
DMARC A _dmarc TXT record I added myself

Here's a spot where it's easy to mismatch tutorials: many tutorials online say "one TXT + one MX," but what I saw was CNAME. The official documentation states that for domains created after August 2026, SPF-related records may be provided in CNAME form. Go by what your own dashboard's Records page shows; don't copy others.

After adding DKIM and SPF, I added a DMARC record myself, starting with the most permissive policy:

_dmarc.example.com TXT
v=DMARC1; p=none;

The official recommendation is also to start with p=none, and after confirming that all sending sources pass, change it to quarantine and reject. If you want to receive DMARC reports, add rua=mailto:you@example.com as well.

From starting to add records until everything took effect, it took me about 6 minutes here. Back in Resend, I clicked Verify, and the domain became verified.

V. Sending the First Email

Create a Key in API Keys. Official supports setting permissions and restricting domains for a Key. My suggestion is to grant only sending permission and limit it to this one domain, so the damage is smaller if it leaks. Keep the Key only in server environment variables; don't put it in code or print it in logs.

The simplest test is a single curl:

test-send.sh
curl -X POST https://api.resend.com/emails \
-H "Authorization: Bearer $RESEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"from":"noreply@example.com","to":["you@example.com"],"subject":"hello","text":"it works"}'

A return of {"id": "..."} means Resend accepted it. My first email was sent to a QQ mailbox, and it went straight to the inbox, not spam. Getting this right on a new domain basically means DKIM/SPF/DMARC are all set up correctly.

VI. Only One Machine Holds the Key: Sending Relay

I didn't want to distribute the Resend Key to every server, so I wrote a tiny sending relay mail-relay: only it holds the Resend Key, and other servers use their own call Keys to call its /send. The interface format stays consistent with the old QQ setup, so old code can switch over by changing only the address.

The core is just two parts, trimmed down as follows:

main.py (excerpt)
API = "https://api.resend.com/emails"
KEY = os.environ["RESEND_API_KEY"]
FROM = os.environ.get("MAIL_FROM", "noreply@example.com")
def build(p):
to = p.get("to"); to = [to] if isinstance(to, str) else to
if not to or len(to) > 5: raise ValueError("bad 'to' (1-5 addresses)")
m = {"from": p.get("from_name") and f'{p["from_name"]} <{FROM}>' or FROM,
"to": to, "subject": p["subject"]}
if p.get("html"): m["html"] = p["html"]
if p.get("body"): m["text"] = p["body"]
if p.get("reply_to"): m["reply_to"] = p["reply_to"]
return m
def resend(m):
r = urllib.request.Request(API, data=json.dumps(m).encode(), method="POST",
headers={"Authorization": "Bearer " + KEY, "Content-Type": "application/json"})
try:
with urllib.request.urlopen(r, timeout=30) as x:
return x.status, json.loads(x.read() or b"{}")
except urllib.error.HTTPError as e:
return e.code, json.loads(e.read() or b"{}")

A few details I think are worth copying:

  • Call Keys are stored only as SHA-256 hashes; compare using hmac.compare_digest during verification, so even if the database leaks, the original value cannot be obtained;
  • One Key per caller, so logs show which machine sent the email, and disabling one doesn't affect the others;
  • from_name is optional: For example, for approval emails I set the display name to “API Quota Approval”, while the address is still the same noreply@;
  • reply_to: My sending domain initially had no receiving capability, so any reply would bounce; therefore, when sending, I set the reply-to address to a mailbox that can receive email.

I put the relay on a free container platform; the benefit is that it doesn't take up my own server. I measured the trade-off at the time: just the handshake from the server to the platform took 0.5–1 seconds, and including forwarding, each email took about 1.5–2 seconds; connecting directly from the server to Resend took only 0.1–0.2 seconds. For notification emails, a second or two makes no difference; if you're sensitive to latency, put it on your own machine.

I hit two small pitfalls during deployment: at the time, the platform reported “no server capacity available,” so I couldn't create a new service and had to reuse a stopped old service and rename it; also, the Resend Key had to be entered as an environment variable in the platform panel myself. After I filled it in the first time, the relay still couldn't read it; in the end, I found it hadn't been added to this service, and it only worked after I clicked Add variable again and selected Secret as the type.

VII. Three Quota Pitfalls

1. The daily quota resets at UTC midnight. At first I wrote “last 24 hours” on the admin page, which was wrong. Official states it clearly: the daily quota is UTC 0:00–24:00, which means it resets at 8 a.m. Beijing time, not on a rolling 24-hour basis. The monthly quota is calculated by billing cycle; in my case it reset on October 27, not on the 1st of each month. When over quota, the API returns 429, and the error is daily_quota_exceeded or monthly_quota_exceeded; Resend will not queue and resend for you.

2. Receiving email also consumes quota. I once enabled Resend's receiving feature for the domain, and only after testing it did I notice that receiving one email also counts as one. The 100-email daily quota is shared between sending and receiving, so it quickly runs out. So later I switched receiving to Cloudflare Email Routing + Workers, leaving Resend to handle only sending. See the previous post for how I did it.

3. Emails sent bypassing the relay are not counted. My login system (Authelia) sends verification codes through Resend's SMTP, bypassing the relay. As a result, the usage shown on the admin page was 3 emails lower than actual. Later I changed the statistics to read Resend's usage API and sent-email list directly, rather than only counting the relay's own logs.

SMTP Ports

As mentioned above, Authelia uses SMTP. Official SMTP configuration is as follows:

Item Value
Host smtp.resend.com
Username resend
Password Your API Key
SMTPS (implicit TLS) 465, 2465
STARTTLS 25, 587, 2587

8. Bounce Monitoring and Duplicate Sending

Bounce alerts. Emails sent through Resend have a last_event status. In the relay there's a background thread that pulls the latest 100 emails every 5 minutes; when it finds bounced, failed, complained, suppressed, or canceled, it pushes a notification to my phone via Bark, with the reason taken from the bounce.diagnosticCode of the individual email's details:

inbound.py (excerpt)
BAD = ("bounced", "failed", "complained", "suppressed", "canceled")
def _bounce_scan():
seen = _kvget("bounce_seen", None); first = seen is None; seen = seen or []
for e in rget("/emails?limit=100").get("data") or []:
if e.get("last_event") not in BAD or e["id"] in seen: continue
seen.append(e["id"])
if first: continue # On first run, only records existing ones; old bounce emails are not pushed.
b = rget("/emails/" + e["id"]).get("bounce") or {}
why = (b.get("diagnosticCode") or [None])[0] or e["last_event"]
_bark("⚠️ Bounced: " + ",".join(e.get("to") or []), why)
_kvset("bounce_seen", seen[-500:])

The first bounce after going live was an email sent to a test address during the few minutes I was switching the receiving MX; the reason was that the address didn't exist, which is normal during a switchover. A local call failure in the relay (e.g., Resend returning a non-2xx) also triggers a separate "send failed" push.

This isn't just for my own awareness: the official requirements state that the bounce rate must stay below 4% and the complaint rate below 0.08%, and exceeding them may get your sending suspended. When testing, don't send to made-up fake addresses.

Duplicate sending. One night at 9 p.m., the scheduled task for the news digest went wrong, and the same email was sent three times. I added two layers of protection:

  1. In the relay, if the digest caller has already successfully sent the same subject within 12 hours, it returns duplicate directly;
  2. Later the digest was changed to only push data to /digest/push, recorded by "date | round", so each round is sent only once, and re-pushes just return "already sent".

Resend actually also provides a Idempotency-Key request header; with the same Key, it won't send duplicates within 24 hours (source). I did my own deduplication at the time; if you're starting from scratch, just adding this header is easier.

9. Launch Checklist

  • Sign up for Resend with email and password, not third-party login
  • Add a domain (a subdomain is best), add the DKIM / SPF records as shown on the Records page, then add _dmarc (with p=none first)
  • Create a Key: send-only permission, restricted to the domain, stored only in environment variables
  • Send a test email to your own QQ / Gmail and confirm it lands in the inbox
  • If the sending domain has no inbox, set up reply_to
  • Remember the daily quota resets at 8 a.m. Beijing time, and receiving also counts toward the quota
  • Set up bounce alerts and deduplication, and don't send to fake addresses when testing

I also have a rule for my own testing: don't connect directly to Resend; create a separate test Key that goes through the relay, so test traffic also lands in the logs and is clearly separated from production calls.

The previous post covered receiving, and this one covers sending; together, an idle domain can be used as a complete notification mailbox. If you have any questions, feel free to leave a comment below.

Share Article

If this article helped you, please share it with others!

Resend Email Sending from 0 to Launch: Domain Verification, Sending Relay, and Bounce Monitoring
https://codqor.com/posts/resend-email-sending-setup/
Author
Liam
Published at
Related PostsSmart
1
Cloudflare Email Routing + Worker: Build a Free Domain Email with Catch-all and Bark Push
TechSkip paid business email: use Cloudflare Email Routing's catch-all to hand all mail for your domain to an Email Worker, forward it to your own service for archiving, automatically store failures in KV for retry, and push new mail to your iPhone via Bark. Complete code running in production is included.
2
My 256MB Router Can’t Run OpenClash, So I Built TinyLane and Open-Sourced It
TechThe Xiaomi AX3000T has only 256 MB of RAM, making OpenClash too much of a strain, so I packaged the sing-box core, a Go daemon, and a mobile panel into a single binary called TinyLane, with my daily readings at about 35 MB for the core and 20–28 MB for the panel. This article explains why I wrote it, what it can do, the memory pitfalls I hit, and how to install it; the project is open-sourced under GPL-3.0.
3
One API for Multiple TTS Providers: OpenAI Standard Parameter Mapping (MOSS Example)
TechWhen creating voiceovers for short videos, I used Edge TTS, Gemini, and MOSS together, each with different parameters. I later added /v1/audio/speech to my AI relay: clients call it using the OpenAI standard format while the gateway maps parameters per provider (for MOSS, just one line: voice→voice_id), and this article covers the parameter comparison table, mapping implementation, usage examples, and pitfalls.
4
Self-Hosting an Astro Blog: Pitfalls with R2 Image Hosting, D1, Caddy, and SEO
Techcodqor.com is itself an Astro static blog: posts are stored in Cloudflare D1, images in R2, pages are served from its own server via Caddy, comments use Turnstile, and there is an English mirror. This article records the build process and pitfalls in real chronological order, including overly long Bing titles, missed noindex directives, a build machine being cooled down, and the remediation approach after AdSense rejected the site for "low-value content."
5
Xiaomi AX3000T Follow-up: OpenClash Primary/Backup Routing, WireGuard Coexistence, and Lag Troubleshooting
TechTwo weeks after flashing OpenWrt on the AX3000T: switching routing from HomeProxy to OpenClash (Meta core) with primary/backup lines, running WireGuard remote management alongside OpenClash, and tracing cross-ocean link lag from 41 KB/s to 7–8 MB/s.
Random PostsRandom

Comments

Leave a comment

Share your thoughts

Shown after review
Leave the name empty to post as “Anonymous”0 / 3000

Comments

Newest first · 5 at a time

Loading comments…

Profile Image of the Author
Liam
Notes on tech, life, and thoughts.
Categories
Tags
Latest Moments
Site Statistics
Posts
21
Categories
4
Tags
72
Total Words
87,292
Running Days
0 days
Last Activity
0 days ago
Table of Contents