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

# Introduction

# Send Emails with PHP

> Use the official **isend.ai PHP SDK** to send emails with templates via your favorite email provider.

***

## 1. Install

Install the isend.ai PHP SDK via Composer:

```bash theme={null}
composer require isend-ai/php-sdk
```

***

## 2. Send an Email Using a Template

Here's how to send a transactional email using a template ID and `dataMapping`.

```php theme={null}
<?php

require_once 'vendor/autoload.php';

use ISend\ISendClient;

// Initialize the client with your API key
$client = new ISendClient('your-api-key-here');

// Prepare email data
$emailData = [
    'template_id' => 124,
    'to' => 'hi@isend.ai',
    'dataMapping' => [
        'name' => 'ISend'
    ]
];

// Send the email
$response = $client->sendEmail($emailData);

print_r($response);
```

***

## 3. Error Handling

The SDK throws an exception on failure. Wrap your logic in a try/catch block for robustness.

```php theme={null}
try {
    $response = $client->sendEmail([
        'template_id' => 124,
        'to' => 'hi@isend.ai',
        'dataMapping' => [
            'name' => 'ISend'
        ]
    ]);
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
```

***

## 4. GitHub Repo

Check out the repository on GitHub:

[**→ View PHP Repo**](https://github.com/isend-ai/php-sdk)

***

## Requirements

* PHP 5.6 or higher
* cURL extension enabled
