---
title: "PHP"
description: "Send your first email from a plain PHP script with the Bird PHP SDK: install messagebird/sdk, call email->send, and run it."
canonical: "https://bird.com/docs/get-started/quickstarts/php/email"
---

# PHP

Send an email from a plain PHP script with `messagebird/sdk`. You need a Bird API key: create one in **Developers** > **API keys** ([Send your first email](/docs/get-started/send-your-first-email) walks through it), then export it as `BIRD_API_KEY`.

## 1. Install

```bash
composer require messagebird/sdk
mkdir -p examples
```

The SDK requires PHP 8.2+ and automatically discovers an installed [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP client.

## 2. Send

Create `examples/quickstart-email.php` so the generated example's autoload path resolves correctly:

```php
<?php

// Send your first email. Set BIRD_API_KEY in your environment, then run:
//   php examples/quickstart-email.php

declare(strict_types=1);

require __DIR__ . '/../vendor/autoload.php';

use MessageBird\Bird;

$bird = new Bird(getenv('BIRD_API_KEY') ?: '');

$message = $bird->email->send(
    from: 'Bird <onboarding@messagebird.dev>',
    to: ['delivered@messagebird.dev'],
    subject: 'Hello from Bird',
    html: '<p>My first Bird email.</p>',
);

echo $message->getId(), ' ', $message->getStatus(), "\n";
```

`onboarding@messagebird.dev` is Bird's shared onboarding sender and `delivered@messagebird.dev` is a [sandbox recipient](/docs/guides/email/testing-sandbox) that always delivers: no domain verification needed. The SDK infers the region from your key's `bk_us1_` / `bk_eu1_` prefix (no base URL to configure) and auto-generates an `Idempotency-Key` per call, so retried sends are safe.

## 3. Run it

```bash
php examples/quickstart-email.php
```

The script prints the message ID and status:

```text
em_01ky7ma8y2es1s2akzk53tmjn0 accepted
```

`accepted` is the API's `202`: Bird has the message and delivers it asynchronously. Fetch it by its `em_` ID with `$bird->email->get($message->getId())` and watch the status move to `delivered`.

## Next steps

- [PHP SDK](/docs/sdks/php): the full client, error model, and webhook verification.
- [Send your first email](/docs/get-started/send-your-first-email): creating an API key and the full set of sandbox addresses.
- [Sending domains](/docs/guides/email/sending-domains): verify your own domain for production sending.
- [Email API reference](/docs/api/reference/create-email-message): the full request and response schema.

## Related resources

- [Getting started with email](/learn/email/getting-started-with-email) (video)
- [Should I use a Bird SDK or call the API directly?](/explained/platform/should-i-use-an-sdk-or-call-the-api-directly) (answer)
- [Email](/email-api) (product)
- [Build your first integration](/learn/paths/integration) (course)

[Get an implementation brief](/learn/workspace?topic=email)
