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

# PHP SDK Quickstart

> Learn how to configure and send your first email with SendPost PHP SDK

## Prerequisites

To get the most out of this guide, you'll need to:

* [**Create a SendPost Account**](https://app.sendpost.io/register)
* [**Install PHP 7.4+**](https://www.php.net/downloads.php)
* A **Sub-Account API Key** from your SendPost dashboard

<Info>
  You can find your API keys in your [SendPost
  Dashboard](https://app.sendpost.io). Make sure to use your Sub-Account API Key
  for sending emails.
</Info>

## 1. Install

### **Composer**

To install the bindings via [<u>Composer</u>](https://getcomposer.org/), use the following command on the command line:

```shellscript shell theme={null}
composer require sendpost/php-sdk
```

Or, add the following to `composer.json`:

```json composer.json theme={null}
  "require": {
      "sendpost/php-sdk": "*"
  }
```

Then run `composer install`

### **Manual Installation**

Download the files and include `autoload.php`:

```php theme={null}
<?php
require_once('/path/to/sendpost/vendor/autoload.php');
```

## 2. Getting Started

```php PHP theme={null}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$client = new GuzzleHttp\Client();

$apiInstance = new sendpost\api\EmailApi($client);

$x_sub_account_api_key = 'your_api_key'; // Sub-Account API Key
$email_message = new \sendpost\model\EmailMessage(); 
$email_message->setSubject('Hello World');
$email_message->setHtmlBody('<strong>it works!</strong>');

$from = new \sendpost\model\From();
$from->setEmail('richard@piedpiper.com');

$to = new \sendpost\model\To();
$to->setEmail('gavin@hooli.com');
$email_message->setTo(array($to));
$email_message->setFrom($from);

try {
    $result = $apiInstance->sendEmail($x_sub_account_api_key, $email_message);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling EmailApi->sendEmail: ', $e->getMessage(), PHP_EOL;
}
```

<Warning>
  Make sure your sender email domain is verified in your SendPost account before
  sending emails.
</Warning>

## 3. Next Steps

Explore more examples and use cases:

<Columns cols={3}>
  <Card title="PHP SDK" icon="php" href="https://packagist.org/packages/sendpost/sendpost-php-sdk">
    View the official SDK package on Packagist
  </Card>

  <Card title="SDK Examples" icon="github" href="https://github.com/sendpost/sendpost-examples-php">
    Comprehensive email sending examples
  </Card>

  <Card title="ESP Workflow Example" icon="diagram-project" href="https://github.com/sendpost/php-esp-example">
    Full-featured example app with comprehensive ESP workflow
  </Card>
</Columns>
