Send and receive email in PHP (without using mail functions)
Streamline Your Email Handling with MailSlurp's PHP Email API - Create Test Accounts, Send/Receive Emails, and Process Attachments in Code and Tests
Use MailSlurp's free PHP email API to send and receive real emails in code and tests. Install with composer or download and vendor the library. Compatible with Laravel, Symfony, Wordpress and more. Create test email accounts, listen for inbound emails, process attachments and more in PHP.
Installing MailSlurp in PHP
If you use the composer package manager 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"
}
}
Basic usage (creating an email address)
To create a new email address use the inbox controller:
<?php
public function test_canCreateInboxes(): void
{
// create an inbox controller with config
$inboxController = new MailSlurpApisInboxControllerApi(null, $this->config);
// create inbox
$inbox = $inboxController->createInbox();
// assert on properties
$this->assertNotNull($inbox->getId());
$this->assertStringContainsString("@mailslurp.com", $inbox->getEmailAddress());
}
Get started
To take the next step sign up for a free account and read the documentation: