Back to Coding

How Do You Send Email From an App?

How Do You Send Email From an App?
AI Tutorials Team 2 April 2026

Sending an email from an application takes about four lines. Getting it to arrive in somebody's inbox rather than their spam folder is an entirely separate problem, and it is the one that catches people out.

Why does the obvious approach fail?

Because mail from an unknown server with no reputation is treated with suspicion, correctly. Providers filter aggressively, and a message from a newly created address on a small server has none of the signals that mark legitimate mail.

Some hosting platforms also block outbound mail entirely, which is a common surprise.

What should you use instead?

A transactional email provider. They maintain the reputation, handle the protocol details, report what happened to each message and offer a free tier adequate for a small application.

This is one of the clearer cases where building it yourself has no upside at all.

What has to be configured?

  • Authentication records in DNS. Which prove you are permitted to send as your domain.
  • A policy record. Telling receivers what to do with messages that fail.
  • A real reply address. Which somebody monitors.
  • A sending domain you control. Not a free mailbox provider.

The DNS records are the part that determines whether anything arrives, and they take twenty minutes once.

What is the difference between kinds of mail?

Transactional mail is a response to something somebody did: a reset link, a receipt, a confirmation. Marketing mail is sent because you decided to send it.

They have different expectations, different deliverability characteristics and different legal requirements, and mixing them on the same sending domain damages the first.

What are the UK requirements for marketing mail?

Consent for most cases, a clear identification of who is sending, and a working unsubscribe that takes effect promptly. The rules apply to a small operation exactly as to a large one, and the regulator publishes accessible guidance.

Transactional mail sits outside most of this, which is another reason to keep the two separate.

Bounces and complaints are worth handling as well, since continuing to send to an address that rejects mail damages your sending reputation for everybody else.

What does generated code miss?

Failure handling and rate limits. Sending is a network call that can fail, and a generated implementation typically assumes success, so an unavailable provider produces a silent loss rather than a retry.

Handle send failures explicitly: retry with a delay, log what failed and to whom, and never let a failed email break the operation that triggered it. What happens if the provider is down for an hour?

Why should a failed email not break the operation?

Because the email is usually secondary. Somebody registering an account should not have the registration fail because a confirmation message could not be sent, and generated code frequently couples the two.

What should you test?

Delivery to several different providers, since filtering differs substantially between them. A message arriving reliably in one inbox tells you very little about the others.

What should the messages themselves look like?

Plain and short. Elaborate templates increase the chance of being filtered, look worse in clients that strip styling, and take longer to write than the content deserves.

A transactional message needs to say what happened, what the person should do, and who it is from. A reset link needs an expiry mentioned and a note about what to do if they did not request it. Those details matter more than the design, and they are exactly what generated templates leave out in favour of a header image and a coloured button.

What is the setup worth doing first?

A provider account, the DNS records, and one test message to three different addresses. An hour, before you build anything that depends on email, and it prevents discovering the problem on the day of launch.