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

# Sending examples

# Sending examples

Minimal examples to send email with Mailofly.

You'll need:

* `MAILOFLY_API_KEY` — from [API keys](/docs/getting-started/api-keys.md)
* `acc_…` — optional; from [Accounts](sending-accounts.md) (auto-selected when omitted)

***

## Send email (transactional)

> [tab] cURL
>
> ```bash theme={null}
> curl -X POST https://api.mailofly.com/emails \
>   -H "Authorization: Bearer $MAILOFLY_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "from": "Acme <onboarding@example.com>",
>     "to": ["you@example.com"],
>     "subject": "Hello from Mailofly",
>     "html": "<p>This is a test email.</p>"
>   }'
> ```

> [tab] Node.js
>
> ```ts theme={null}
> import { Mailofly } from "@mailofly/node";
>
> const client = new Mailofly({ apiKey: process.env.MAILOFLY_API_KEY! });
>
> const { id } = await client.emails.send({
>   from: "Acme <onboarding@example.com>",
>   to: ["you@example.com"],
>   subject: "Hello from Mailofly",
>   html: "<p>This is a test email.</p>",
> });
> ```

> [tab] Python
>
> ```python theme={null}
> import os
> from mailofly import Mailofly
>
> client = Mailofly(os.environ["MAILOFLY_API_KEY"])
>
> result = client.emails.send({
>     "from": "Acme <onboarding@example.com>",
>     "to": ["you@example.com"],
>     "subject": "Hello from Mailofly",
>     "html": "<p>This is a test email.</p>",
> })
> ```

> [tab] PHP
>
> ```php theme={null}
> $client = new \Mailofly\Client(getenv('MAILOFLY_API_KEY'));
>
> $result = $client->emails->send([
>     'from' => 'Acme <onboarding@example.com>',
>     'to' => ['you@example.com'],
>     'subject' => 'Hello from Mailofly',
>     'html' => '<p>This is a test email.</p>',
> ]);
> ```

***

## Batch send (up to 100 emails)

Post a JSON **array** to `POST /emails/batch`. Each item uses the same shape as single send. Attachments are not supported in batch.

> [tab] cURL
>
> ```bash theme={null}
> curl -X POST https://api.mailofly.com/emails/batch \
>   -H "Authorization: Bearer $MAILOFLY_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '[
>     {
>       "from": "Acme <onboarding@example.com>",
>       "to": ["foo@example.com"],
>       "subject": "hello world",
>       "html": "<h1>it works!</h1>"
>     },
>     {
>       "from": "Acme <onboarding@example.com>",
>       "to": ["bar@example.com"],
>       "subject": "world hello",
>       "html": "<p>it works!</p>"
>     }
>   ]'
> ```

> [tab] Node.js
>
> ```ts theme={null}
> const { data } = await client.batch.send([
>   {
>     from: "Acme <onboarding@example.com>",
>     to: ["foo@example.com"],
>     subject: "hello world",
>     html: "<h1>it works!</h1>",
>   },
>   {
>     from: "Acme <onboarding@example.com>",
>     to: ["bar@example.com"],
>     subject: "world hello",
>     html: "<p>it works!</p>",
>   },
> ]);
> ```

Response: `{ "data": [{ "id": "…" }, …] }` — same order as the request array.

***

## With a template

```json theme={null}
POST /emails
{
  "from": "Acme <onboarding@example.com>",
  "to": ["you@example.com"],
  "template": {
    "id": "template-uuid",
    "variables": { "first_name": "Alex" }
  }
}
```

***

## Next

* [Emails API](https://docs.mailofly.com/api/emails)
* [SDKs](/docs/sdks.md)


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