PHP Documentation

Create test email accounts in PHP. Send and receive emails in Laravel, Symfony, Wordpress and more.

MailSlurp\CommonOperationsApi

All URIs are relative to https://api.mailslurp.com

Method HTTP request Description
createNewEmailAddress POST /newEmailAddress Create new email address
deleteEmail DELETE /deleteEmail Delete an email
deleteEmailAddress DELETE /deleteEmailAddress Delete email address and its emails
emptyInbox DELETE /emptyInbox Delete all emails in an inbox
sendEmailSimple POST /sendEmail Send an email from a random email address
waitForEmailCount GET /waitForEmailCount Wait for and return count number of emails
waitForLatestEmail GET /waitForLatestEmail Fetch inbox's latest email or if empty wait for email to arrive
waitForMatchingEmail POST /waitForMatchingEmails Wait or return list of emails that match simple matching patterns
waitForNthEmail GET /waitForNthEmail Wait for or fetch the email with a given index in the inbox specified

createNewEmailAddress

\MailSlurp\Models\Inbox createNewEmailAddress()

Create new email address

Returns an Inbox with an id and an emailAddress

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$apiInstance = new MailSlurp\Api\CommonOperationsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->createNewEmailAddress();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CommonOperationsApi->createNewEmailAddress: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

This endpoint does not need any parameter.

Return type

\MailSlurp\Models\Inbox

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

deleteEmail

deleteEmail($email_id)

Delete an email

Deletes an email

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$apiInstance = new MailSlurp\Api\CommonOperationsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$email_id = 'email_id_example'; // string | emailId

try {
    $apiInstance->deleteEmail($email_id);
} catch (Exception $e) {
    echo 'Exception when calling CommonOperationsApi->deleteEmail: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

Name Type Description Notes
email_id string emailId

Return type

void (empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

deleteEmailAddress

deleteEmailAddress($inbox_id)

Delete email address and its emails

Deletes an inbox

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$apiInstance = new MailSlurp\Api\CommonOperationsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$inbox_id = 'inbox_id_example'; // string | inboxId

try {
    $apiInstance->deleteEmailAddress($inbox_id);
} catch (Exception $e) {
    echo 'Exception when calling CommonOperationsApi->deleteEmailAddress: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

Name Type Description Notes
inbox_id string inboxId

Return type

void (empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

emptyInbox

emptyInbox($inbox_id)

Delete all emails in an inbox

Deletes all emails

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$apiInstance = new MailSlurp\Api\CommonOperationsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$inbox_id = 'inbox_id_example'; // string | inboxId

try {
    $apiInstance->emptyInbox($inbox_id);
} catch (Exception $e) {
    echo 'Exception when calling CommonOperationsApi->emptyInbox: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

Name Type Description Notes
inbox_id string inboxId

Return type

void (empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

sendEmailSimple

sendEmailSimple($send_email_options)

Send an email from a random email address

To specify an email address first create an inbox and use that with the other send email methods

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$apiInstance = new MailSlurp\Api\CommonOperationsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$send_email_options = new \MailSlurp\Models\SendEmailOptions(); // \MailSlurp\Models\SendEmailOptions | sendEmailOptions

try {
    $apiInstance->sendEmailSimple($send_email_options);
} catch (Exception $e) {
    echo 'Exception when calling CommonOperationsApi->sendEmailSimple: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

Name Type Description Notes
send_email_options \MailSlurp\Models\SendEmailOptions sendEmailOptions

Return type

void (empty response body)

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: Not defined

[Back to top] [Back to API list] [Back to Model list] [Back to README]

waitForEmailCount

\MailSlurp\Models\EmailPreview[] waitForEmailCount($count, $inbox_id, $timeout)

Wait for and return count number of emails

Will only wait if count is greater that the found emails in given inbox.If you need to wait for an email for a non-empty inbox see the other receive methods.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$apiInstance = new MailSlurp\Api\CommonOperationsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$count = 56; // int | Number of emails to wait for. Must be greater that 1
$inbox_id = 'inbox_id_example'; // string | Id of the inbox we are fetching emails from
$timeout = 56; // int | Max milliseconds to wait

try {
    $result = $apiInstance->waitForEmailCount($count, $inbox_id, $timeout);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CommonOperationsApi->waitForEmailCount: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

Name Type Description Notes
count int Number of emails to wait for. Must be greater that 1 [optional]
inbox_id string Id of the inbox we are fetching emails from [optional]
timeout int Max milliseconds to wait [optional]

Return type

\MailSlurp\Models\EmailPreview[]

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

waitForLatestEmail

\MailSlurp\Models\Email waitForLatestEmail($inbox_id, $timeout)

Fetch inbox's latest email or if empty wait for email to arrive

Will return either the last received email or wait for an email to arrive and return that. If you need to wait for an email for a non-empty inbox see the other receive methods.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$apiInstance = new MailSlurp\Api\CommonOperationsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$inbox_id = 'inbox_id_example'; // string | Id of the inbox we are fetching emails from
$timeout = 56; // int | Max milliseconds to wait

try {
    $result = $apiInstance->waitForLatestEmail($inbox_id, $timeout);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CommonOperationsApi->waitForLatestEmail: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

Name Type Description Notes
inbox_id string Id of the inbox we are fetching emails from [optional]
timeout int Max milliseconds to wait [optional]

Return type

\MailSlurp\Models\Email

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

waitForMatchingEmail

\MailSlurp\Models\EmailPreview[] waitForMatchingEmail($match_options, $count, $inbox_id, $timeout)

Wait or return list of emails that match simple matching patterns

Results must also meet provided count. Match options allow simple CONTAINS or EQUALS filtering on SUBJECT, TO, BCC, CC, and FROM.

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$apiInstance = new MailSlurp\Api\CommonOperationsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$match_options = new \MailSlurp\Models\MatchOptions(); // \MailSlurp\Models\MatchOptions | matchOptions
$count = 56; // int | Number of emails to wait for. Must be greater that 1
$inbox_id = 'inbox_id_example'; // string | Id of the inbox we are fetching emails from
$timeout = 56; // int | Max milliseconds to wait

try {
    $result = $apiInstance->waitForMatchingEmail($match_options, $count, $inbox_id, $timeout);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CommonOperationsApi->waitForMatchingEmail: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

Name Type Description Notes
match_options \MailSlurp\Models\MatchOptions matchOptions
count int Number of emails to wait for. Must be greater that 1 [optional]
inbox_id string Id of the inbox we are fetching emails from [optional]
timeout int Max milliseconds to wait [optional]

Return type

\MailSlurp\Models\EmailPreview[]

Authorization

API_KEY

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

waitForNthEmail

\MailSlurp\Models\Email waitForNthEmail($inbox_id, $index, $timeout)

Wait for or fetch the email with a given index in the inbox specified

Example

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: API_KEY
$config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKey('x-api-key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = MailSlurp\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-api-key', 'Bearer');

$apiInstance = new MailSlurp\Api\CommonOperationsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$inbox_id = 'inbox_id_example'; // string | Id of the inbox we are fetching emails from
$index = 56; // int | Zero based index of the email to wait for
$timeout = 56; // int | Max milliseconds to wait

try {
    $result = $apiInstance->waitForNthEmail($inbox_id, $index, $timeout);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CommonOperationsApi->waitForNthEmail: ', $e->getMessage(), PHP_EOL;
}
?>

Parameters

Name Type Description Notes
inbox_id string Id of the inbox we are fetching emails from [optional]
index int Zero based index of the email to wait for [optional]
timeout int Max milliseconds to wait [optional]

Return type

\MailSlurp\Models\Email

Authorization

API_KEY

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]