Download the PHP package mailslurp/mailslurp-client-php without Composer
On this page you can find all versions of the php package mailslurp/mailslurp-client-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mailslurp/mailslurp-client-php
More information about mailslurp/mailslurp-client-php
Files in mailslurp/mailslurp-client-php
Package mailslurp-client-php
Short Description MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. 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
License unlicense
Homepage https://www.mailslurp.com
Informations about the package mailslurp-client-php
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:
Video tutorial
Quick links
- API documentation
- Download PHP Plugin
- GitHub Repository
- Official PHP Library
- Full method documentation
Examples
- Laravel Mailable/Notification setup
- PHP Codeception Selenium Example
- PHPUnit Example
- PHP send email with SMTP
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.
See the examples page for code examples and use with common frameworks.
See the method documentation for a list of all functions.
Get an API Key
You need a free MailSlurp account to use the service. Sign up for a free account first.
Once signed up login your dashboard. Find your API Key and copy the code. You'll need this to configure the MailSlurp client in PHP.
Copy your API Key from the MailSlurp dashboard.
PHP Setup
The client is tested for PHP 7 and requires the following non-default PHP extensions to be installed:
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
There are several ways to install MailSlurp.
a) Composer dependency
If you use the composer package manager you can run:
Or add it to your composer.json
file:
Then include the library with the composer autoload convention:
b) Manual installation
Alternatively you can download the PHP Library and include it in your project's root directory.
Then include the files to have access to MailSlurp in your code:
Create an API instance
To call the MailSlurp API you must create an instance of the controller you wish to access. Each instance must be configured with an API Key. See method documentation for a list of all controllers and methods.
Configure the API Key
Create a controller
Basic usage
A common use case is to create a new email address, send it an email and then receive the contents:
Create an email address
To create an email address use the inbox controller to create a new inbox. Inboxes have real email addresses and can send and receive emails and attachments.
Send an email
Here is a simple example of sending an email:
Read an email
You can use the WaitFor controller methods to wait for an expected email to arrive in an inbox:
Then call it like so:
Fetch emails
You can get emails from an inbox using the inbox controller:
You can also fetch in paginated form:
Get an email
Get an email directly by ID using the email controller:
SMTP access (PHPMailer, mail function etc.)
SMTP inboxes provide IMAP and SMTP access credentials via the getImapSmtpAccess
function. Use these to configure PHPMailer, PearMailer or other SMTP sending clients. First create an SMTP_INBOX
:
Then use the access settings to configure PHPMailer:
List inboxes
Inbox lists are paginated.
Send an email with more options
To send an email first create an inbox. Then use the sendEmail
method on the InboxController
and pass it the sender inbox's ID and email options.
Attachments
Using attachments in PHP is easy. For sending attachments you must first upload each file and store the returned attachment IDs.
For sending use these IDs with SendEmailOptions
. Received email attachments can be downloaded using the EmailControllerApi
.
To send the attachments use like so:
Receive an email
You can receive emails in PHP using MailSlurp. First create an inbox then call a waitFor
method. These methods wait until a new unread email has arrived and return it.
Larger example:
Receive attachment
Test example:
Extract email content
You can use regex to parse codes or statements for email bodies like so:
SDK Documentation
For more functions and examples read the library documentation or see the PHP guides.
All versions of mailslurp-client-php with dependencies
ext-curl Version *
ext-json Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.3
guzzlehttp/psr7 Version ^1.7 || ^2.0