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

# Schedule Emails

> Set your emails to go out at exactly the right moment. Like a time machine, but for email.

# Schedule Emails ⏰

Ever written a "we're launching tomorrow!" email at midnight but didn't want to send it until 9am? That's what scheduled emails are for.

With Mailofly, you can tell an email to go out up to **72 hours in the future**. You don't need cron jobs, background workers, or anything complicated. Just include `scheduled_at` in your request and Mailofly holds it until the right moment.

***

## How to schedule an email

Add `scheduled_at` to your normal send request. It needs to be an **ISO-8601 date string** (the international format for dates and times):

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

const mailofly = new Mailofly("mfly_live_your_api_key");

// Tomorrow at 9am UTC
const tomorrowMorning = new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString();

const { data } = await mailofly.emails.send({
  from: "Team <hello@yourcompany.com>",
  to: ["user@example.com"],
  subject: "Big news coming your way 🚀",
  html: "<p>We just launched something huge. Check it out!</p>",
  scheduled_at: tomorrowMorning,
});

console.log("Scheduled! ID:", data.id);
```

***

## Changed your mind? Cancel it.

As long as the scheduled time hasn't arrived yet, you can cancel:

```typescript theme={null}
await mailofly.emails.cancel("msg_01J8G52XYZ9A8B7C6D");
```

Or via the API directly:

```http theme={null}
DELETE https://api.mailofly.com/emails/{id}/cancel
Authorization: Bearer YOUR_API_KEY
```

After cancelling:

* ✅ Status in your [Logs](https://www.mailofly.com/user/emails) changes to `cancelled`
* 🚫 The email will NOT be sent to the recipient
* 💳 No sending credits are used for cancelled emails

***

## Limits & tips

* ⏳ Max scheduling window: **72 hours** from now
* 🕐 Times are in UTC unless you specify a timezone offset
* 💡 Use `scheduled_at` with batch sends too — schedule 100 emails at once


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