> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Send an Email

> Your first Mailofly send request — in every language we support.

# Send an Email ✉️

Okay, here's the fun part. Let's actually send something.

At the end of this page you'll have a working email going out from your app. Copy the code for your language, swap in your real API key, and go.

***

## The API endpoint

Every email goes through this single endpoint:

```http theme={null}
POST https://api.mailofly.com/emails
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
```

***

## Code examples

Pick your language 👇

### cURL

```bash theme={null}
curl -X POST https://api.mailofly.com/emails \
  -H "Authorization: Bearer mfly_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "Acme <notifications@yourcompany.com>",
    "to": ["alex@example.com"],
    "subject": "Welcome to Acme!",
    "html": "<h1>Welcome, Alex!</h1><p>So glad you joined us.</p>"
  }'
```

***

### Node.js / TypeScript

```typescript theme={null}
import { Mailofly } from "@mailofly/node";

const mailofly = new Mailofly("mfly_live_your_api_key");

const { data, error } = await mailofly.emails.send({
  from: "Acme <notifications@yourcompany.com>",
  to: ["alex@example.com"],
  subject: "Welcome to Acme!",
  html: "<h1>Welcome, Alex!</h1><p>So glad you joined us.</p>",
});

if (error) {
  console.error("Oops, something went wrong:", error);
} else {
  console.log("Email is flying! ID:", data.id);
}
```

***

### Python

```python theme={null}
from mailofly import Mailofly

client = Mailofly(api_key="mfly_live_your_api_key")

response = client.emails.send({
    "from": "Acme <notifications@yourcompany.com>",
    "to": ["alex@example.com"],
    "subject": "Welcome to Acme!",
    "html": "<h1>Welcome, Alex!</h1><p>So glad you joined us.</p>",
})

print(f"Email sent! ID: {response['id']}")
```

***

## What can you put in the request?

| Field | Type | Needed? | What it does |
| :- | :- | :- | :- |
| `from` | string | ✅ Yes | Who's sending. Must be your verified domain. Like `Hello <hi@company.com>` |
| `to` | string\[] | ✅ Yes | Who's receiving. Up to 50 at a time. |
| `subject` | string | ✅ Yes | The subject line. Don't make it boring. |
| `html` | string | ✓ One of these | The pretty HTML version of your email. |
| `text` | string | ✓ One of these | Plain text fallback for email clients that don't do HTML. |
| `reply_to` | string\[] | Optional | Where replies go if the recipient hits reply. |
| `cc` | string\[] | Optional | Carbon copy — they get a copy too. |
| `bcc` | string\[] | Optional | Secret copy — they get it but nobody else sees their name. |
| `scheduled_at` | string | Optional | Send it later. ISO-8601 format like `2026-09-15T10:00:00Z`. |
| `attachments` | object\[] | Optional | Files to attach. PDFs, images, whatever. |
| `tags` | object | Optional | Label it for filtering in your logs and analytics. |

> You need at least one of `html`, `text`, or `template_id` — otherwise what's the email, just a subject line?

***

## What you get back

When it works, you'll get something like this:

```json theme={null}
{
  "id": "msg_01J8G52XYZ9A8B7C6D",
  "from": "notifications@yourcompany.com",
  "to": ["alex@example.com"],
  "created_at": "2026-09-11T00:30:00Z"
}
```

Save that `id` — you can use it to look up the email later in your [Logs](https://www.mailofly.com/user/emails).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.