MailSlurp is an end-to-end email testing service. It has a web-app for managing your account and a REST API for sending and receiving emails from randomly generated email addresses.
MailSlurp was built to test the integration of email services within an app. If your application relies on the sending or receiving of emails, then MailSlurp will let you test that functionality. This is a more common need than you might think: if your app has a sign up process that requires email verification, how do you currently test that?
Every API request requires a valid API Key appended as a query parameter. To obtain an API Key visit your account dashboard.
The general flow is as follows:
- Create a new inbox during a test. The email address will be returned in the apiReponse.
- Send an email to that address or trigger an action in your test that does so.
- Fetch the email for your new inbox and check if its content is what you expected, or use the content in another action.
- There is an official Javascript SDK available on npm.
- This PHP version was generated from swagger JSON definition using swagger-codegen and adapted for use with PHP 7.0+ (see commits for a full list of changes).
The Mailslurp API code is owned by PettmanUG and uses a proprietary software licence. The SDKs are free to use in any project and have an ISC licence.
To report bugs or request features please see the contact page. For help see support.
PHP 7.0 and later
To install the bindings via Composer, run command
composer require rvalitov/mailslurp-php
Or manually add the following to composer.json
:
{
"require": {
"rvalitov/mailslurp-php": "^0.0.1"
}
}
Then run composer install
Download the files and include autoload.php
:
require_once('/path/to/MailSlurp-PHP/vendor/autoload.php');
Note. Tests are not implemented yet!
To run the unit tests:
composer install
./vendor/bin/phpunit
Please follow the installation procedure and then run the following:
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new Swagger\Client\Api\AccountControllerApi(
// 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()
);
$jwt_token = "jwt_token_example"; // string | Cognito ID obtained during login
$stripe_token = "stripe_token_example"; // string | Stripe user payment confirmation token
try {
$result = $apiInstance->createSubscriptionUsingPOST($jwt_token, $stripe_token);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling AccountControllerApi->createSubscriptionUsingPOST: ', $e->getMessage(), PHP_EOL;
}
?>
All URIs are relative to https://api.mailslurp.com
Class | Method | HTTP request | Description |
---|---|---|---|
AccountControllerApi | createSubscriptionUsingPOST | POST /subscription | Upgrade a user to paid |
AccountControllerApi | getAccountsUsingGET | GET /accounts | List available account types |
InboxControllerApi | createRandomInboxUsingPOST | POST /inboxes | Create an inbox |
InboxControllerApi | deleteInboxUsingDELETE | DELETE /inboxes/{uuid} | Delete an inbox |
InboxControllerApi | getEmailsForInboxUsingGET | GET /inboxes/{uuid} | Fetch emails for a given inbox |
InboxControllerApi | getListOfInboxesUsingGET | GET /inboxes | List your inboxes |
InboxControllerApi | sendEmailFromUserUsingPOST | POST /inboxes/{uuid} | Send an email |
UserControllerApi | getUserUsingGET | GET /user | Fetch a user |
- AccountDto
- AccountsDto
- ApiReponse
- ApiReponseInboxDto_
- ApiReponseListEmailDto_
- ApiReponseListInboxDto_
- EmailDto
- InboxDto
- SendEmailDto
- UserDto
All endpoints do not require authorization.
If you want to generate the original code from Swagger, use the following commands:
wget http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.3.1/swagger-codegen-cli-2.3.1.jar -O swagger-codegen-cli.jar
java -jar .\swagger-codegen-cli.jar generate -i https://api.mailslurp.com/v2/api-docs -l php -o ./out