PHPackages                             mailslurp/mailslurp-client-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. mailslurp/mailslurp-client-php

ActiveLibrary[HTTP &amp; Networking](/categories/http)

mailslurp/mailslurp-client-php
==============================

MailSlurp is an API for sending and receiving emails and SMS from dynamically allocated email addresses and phone numbers. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - \[Homepage\](https://www.mailslurp.com) - Get an \[API KEY\](https://app.mailslurp.com/sign-up/) - Generated \[SDK Clients\](https://docs.mailslurp.com/) - \[Examples\](https://github.com/mailslurp/examples) repository

17.5.0(3mo ago)654.0k—4.7%7[1 issues](https://github.com/mailslurp/mailslurp-client-php/issues)1unlicensePHPPHP ^7.4 || ^8.0CI failing

Since Aug 27Pushed 3mo agoCompare

[ Source](https://github.com/mailslurp/mailslurp-client-php)[ Packagist](https://packagist.org/packages/mailslurp/mailslurp-client-php)[ Docs](https://www.mailslurp.com)[ RSS](/packages/mailslurp-mailslurp-client-php/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (12)Versions (468)Used By (1)

PHP Email and SMS API - Documentation
=====================================

[](#php-email-and-sms-api---documentation)

Create and manage email addresses and phone numbers in PHP. Send and receive emails, attachments, and SMS in code and tests. Here is a quick example:

```
// configure mailslurp/mailslurp-client-php library
$config = MailSlurp\Configuration::getDefaultConfiguration()
    ->setApiKey('x-api-key', getenv("API_KEY"));
$inboxController = new MailSlurp\Apis\InboxControllerApi(null, $config);
// create an inbox
$inbox = $inboxController->createInboxWithDefaults();
// send an email
$sendOptions = new MailSlurp\Models\SendEmailOptions();
$sendOptions->setTo([$inbox->getEmailAddress()]);
$sendOptions->setSubject("Test");
$sendOptions->setBody("Hello");
$inboxController->sendEmail($inbox->getId(), $sendOptions);
// receive the email
$waitForController = new MailSlurp\Apis\WaitForControllerApi(null, $config);
$email = $waitForController->waitForLatestEmail($inbox->getId(), 120000, true);
$this->assertNotNull($email->getBody());
```

Video tutorial
--------------

[](#video-tutorial)

[![PHP mailslurp tutorial](https://camo.githubusercontent.com/cc0a855ef89b221dcb20f2559da52c519df119e6b1fe79ae1e242e01210bce6c/68747470733a2f2f7777772e6d61696c736c7572702e636f6d2f766964656f2d7468756d626e61696c732f7068702d7475746f7269616c2e6a706567)](https://youtu.be/-gVB7WvHvfw)

Quick links
-----------

[](#quick-links)

- [API documentation](https://docs.mailslurp.com/api/)
- [Download PHP Plugin](https://www.github.com/mailslurp/mailslurp-client-php/)
- [GitHub Repository](https://www.github.com/mailslurp/mailslurp-client-php/)
- [Official PHP Library](https://packagist.org/packages/mailslurp/mailslurp-client-php)
- [Full method documentation](https://php.mailslurp.com/)

Examples
--------

[](#examples)

- [Laravel Mailable/Notification setup](https://www.mailslurp.com/guides/send-email-laravel-mailable-notifications/)
- [PHP Codeception Selenium Example](https://www.mailslurp.com/examples/php-test-email-api-codeception/)
- [PHPUnit Example](https://www.mailslurp.com/examples/phpunit-email-testing/)
- [PHP send email with SMTP](https://www.mailslurp.com/smtp/php-send-email-smtp/)

Get started
-----------

[](#get-started)

MailSlurp is an email API that lets you create email addresses on demand then send and receive emails in code and tests. **No MailServer is required**.

This section describes how to get up and running with the PHP client. To use another language or the REST API see the [developer page](https://www.mailslurp.com/developers/).

See the examples page for [code examples and use with common frameworks](https://www.mailslurp.com/examples/).

See the method documentation for a [list of all functions](https://php.mailslurp.com/).

Get an API Key
--------------

[](#get-an-api-key)

You need a free MailSlurp account to use the service. [Sign up for a free account](https://app.mailslurp.com/sign-up/) first.

Once signed up [login your dashboard](https://app.mailslurp.com/login/). Find your API Key and copy the code. You'll need this to configure the MailSlurp client in PHP.

[![find-api-key](https://camo.githubusercontent.com/99cdf8e6d27466d992008b6e8d96f795fe849854c0a1c641a98bfc28ce85fae6/68747470733a2f2f7777772e6d61696c736c7572702e636f6d2f6173736574732f6775696465732f66696e642d6170692d6b65792e706e67)](https://camo.githubusercontent.com/99cdf8e6d27466d992008b6e8d96f795fe849854c0a1c641a98bfc28ce85fae6/68747470733a2f2f7777772e6d61696c736c7572702e636f6d2f6173736574732f6775696465732f66696e642d6170692d6b65792e706e67)

Copy your API Key from the [MailSlurp dashboard](https://app.mailslurp.com).

PHP Setup
---------

[](#php-setup)

The client is tested for PHP 7 and requires the following non-default PHP extensions to be installed:

```
php-ext-curl
php-xml
php-mbstring
```

Typically, these come with most PHP installations. On Linux they can also be installed like so:

`sudo apt-get install php-ext-curl php-mbstring php-xml`

Add PHP Library
---------------

[](#add-php-library)

There are several ways to install MailSlurp.

### a) Composer dependency

[](#a-composer-dependency)

If you use the [composer package manager](https://getcomposer.org) you can run:

```
composer require mailslurp/mailslurp-client-php
```

Or add it to your `composer.json` file:

```
{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/mailslurp/mailslurp-client-php.git"
    }
  ],
  "require": {
    "mailslurp/mailslurp-client-php": "*@dev"
  }
}
```

Then include the library with the composer autoload convention:

```
