How to Add Email Sending to an AI-Built App

Sending email from an app is two problems: getting the message out of your code, and getting it into an inbox. The second one is where AI-built apps usually fail.

Steve Jefferson
Steve Jefferson
Developer Advocate
11 August 20261 min read

Two decisions, in this order: which service delivers the mail, and how you prove to receiving servers that the mail is really from you. Most explanations of how to add email sending to an AI-built app cover the first decision alone, which is why so many apps end up technically sending email that nobody receives.

The code is genuinely easy. An AI builder will wire up a transactional email API in a few minutes and the test message will arrive in your inbox, because your own provider trusts almost anything on a first send. The failures start later, at volume, and they are quiet: no error, no bounce you notice, just a support ticket three weeks in saying the password reset never came.

Never send mail from your app server

Running your own SMTP server, or using your application host's raw mail capability, will get your messages filtered. Cloud provider IP ranges carry poor sending reputation, most block outbound port 25 anyway, and you have no visibility into whether anything arrived. Use a transactional email API. The category is commoditised, the free tiers cover early usage comfortably, and every one of them handles the parts that are tedious to build.

What you are actually paying for is reputation management, bounce handling, and delivery telemetry. Those are hard to replicate and worthless to build yourself. Any of the mainstream providers will do; the differences that matter at small scale are the quality of the webhook events and how quickly domain verification completes.

Separate the two kinds of email before you build

Transactional

Marketing

Triggered by

A user action

A schedule or campaign

Examples

Password reset, receipt, alert

Newsletter, product update

Consent needed

Implied by the action

Explicit opt-in

Unsubscribe link

Not required

Required

Sending domain

mail.yourdomain.com

news.yourdomain.com

Use separate subdomains from day one. If a marketing send generates complaints, it damages the reputation of that subdomain, and your password reset emails keep arriving. Merge them and one bad campaign takes down your ability to let people log in. This costs nothing to set up in advance and is painful to retrofit, because reputation attaches to the domain and does not transfer when you finally split them.

How to add email sending to an AI-built app that actually reaches inboxes

Three DNS records decide whether receiving servers believe you:

  • SPF: a TXT record listing which servers may send on behalf of your domain.

  • DKIM: a public key in DNS, letting receivers verify a cryptographic signature your provider adds to each message.

  • DMARC: a policy record telling receivers what to do when SPF and DKIM fail, and where to send reports. Defined in RFC 7489.

These are not optional any more. Google's sender guidelines require authentication for bulk senders, and other large providers have converged on similar requirements. An unauthenticated domain does not get a warning, it gets filtered.

Start DMARC at p=none, which reports without enforcing, read the reports for a couple of weeks to confirm nothing legitimate is failing, then move to quarantine and eventually reject. Going straight to reject is how people discover that their invoicing system was also sending mail as their domain. Budget two weeks for this, mostly waiting, and start it before you need it rather than during a launch.

Get the sending code right

Once the provider and DNS are sorted, the implementation has four requirements that AI builders routinely skip:

  1. Send asynchronously. Queue the message and return; do not block an HTTP response on a third-party API call.

  2. Make sends idempotent. A retried webhook that sends a second receipt is a support ticket. Key each send on the event that caused it.

  3. Handle bounces and complaints. Consume the provider's webhook and stop sending to addresses that hard bounce, permanently. Continuing to mail dead addresses is one of the fastest ways to wreck a sending reputation.

  4. Log the provider's message ID against your own record, so a customer saying they never got it becomes a lookup rather than a guess.

The idempotency point deserves emphasis because it is the one that generates real anger. A billing webhook that fires twice and sends two receipts is annoying. A nightly job that re-sends yesterday's alerts because a retry cleared a flag is the kind of thing that gets an app reported as spam by its own users.

That queue is the same infrastructure you will want for other slow work, and it is worth setting up properly rather than as a one-off. If you have not added background processing yet, it pairs naturally with adding analytics to an AI-built app, which has the same shape of problem.

Write the messages so they get through

Content affects delivery more than people expect. Keep a plain text alternative alongside the HTML, since text-only messages score better and some clients prefer them. Avoid link shorteners entirely, because they share reputation with everything else shortened by the same service. Keep the image-to-text ratio sane. Use a real reply-to address that a human reads.

On volume: warm up gradually. Going from zero to ten thousand messages in a day looks exactly like a compromised account. Ramp over a week or two and reputation builds instead of triggering filters. If you are migrating an existing list to a new provider, ramp it too, because the new provider has no history with your recipients.

Test before real users see it

Send to accounts on the three or four largest providers your users actually use, and check whether the message landed in the inbox rather than only whether it was accepted. Delivery acceptance and inbox placement are different things, and your provider's dashboard reports the first one.

Then check the content renders. Email clients support a much narrower slice of HTML and CSS than browsers, and an AI-generated template using a modern layout will collapse in older desktop clients. Keep templates simple, table-based, and boring. Check dark mode, which inverts backgrounds in ways that make a logo on a white block look like a mistake.

What to monitor once it is live

Four numbers, checked monthly rather than obsessively:

  • Hard bounce rate. Above a few percent means your signup flow is accepting addresses it should validate.

  • Complaint rate. This is the one that gets you blocked, and the tolerable threshold is far lower than people expect.

  • Delivery latency. A sudden increase usually means a receiving provider has started throttling you.

  • Open rate on transactional mail, as a rough proxy for whether messages are being seen at all. Treat it as a trend, not a measurement, since image blocking makes the absolute number meaningless.

Set an alert on the first two and check the rest monthly. Complaint rate is the one worth watching closely, because the damage from crossing a receiving provider's threshold is slow to appear and slow to undo: reputation is rebuilt over weeks of clean sending, not by fixing the offending campaign.

FAQ

Can I send email from a free tier?

Yes. Most transactional providers include a few thousand messages a month free, which covers a product with hundreds of users. The constraint you hit first is usually the number of authenticated domains, not the message count.

Why do my emails land in spam?

In order of likelihood: missing or misconfigured SPF and DKIM, sending from a shared IP with poor reputation, a sudden volume spike, or continuing to send to addresses that bounce. Check authentication first, it is the cause most of the time.

Do I need a dedicated IP address?

Not below roughly a hundred thousand messages a month. Shared IPs are managed by the provider and generally have better reputation than a new dedicated IP with no sending history.

How do I handle users replying to automated email?

They will, whatever the address says. Route replies to a real inbox rather than a black hole, and treat that inbox as a support channel. Anything else quietly loses customer messages.

Should I let users choose which emails they receive?

For anything non-essential, yes, and it reduces complaints more effectively than better copy does. Keep security and billing notifications mandatory and say so on the preferences page.

Email is one of the pieces most likely to be technically working and functionally broken, because nothing errors when a message is silently filtered. Set up authentication before your first real send, not after the first complaint. It belongs on the same checklist as the rest of building an app with AI, alongside adding user accounts, which is usually what generates the first email you send.

A CRM is one of the more common places this gets wired in next. how to build a simple CRM with AI covers the data model it needs to plug into.

How did this land?

About the author

Steve Jefferson
Steve Jefferson

Developer Advocate

Steve builds something with Swarmz every week and writes up what worked, what broke, and what he'd do differently. Tutorials and hands-on guides are his lane.

Share

Get the next post in your inbox

One email a month. Product updates, engineering posts, and the best of Built with Swarmz.

I agree to receive emails about AI building tips and Swarmz product news. Unsubscribe any time.