1. Go to this page and download the library: Download railsware/mailtrap-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
railsware / mailtrap-php example snippets
use Mailtrap\Helper\ResponseHelper;
use Mailtrap\MailtrapClient;
use Mailtrap\Mime\MailtrapEmail;
use Symfony\Component\Mime\Address;
$email = (new MailtrapEmail())
->from(new Address('[email protected]'))
->to(new Address('[email protected]'))
->subject('Hello from Mailtrap PHP')
->text('Plain text body');
$response = $mailtrap->send($email);
// Access response body as array (helper optional)
var_dump(ResponseHelper::toArray($response));
use Mailtrap\Helper\ResponseHelper;
use Mailtrap\MailtrapClient;
use Mailtrap\Mime\MailtrapEmail;
use Symfony\Component\Mime\Address;
box ? getenv('MAILTRAP_INBOX_ID') : null; // ->from(new Address($isSandbox ? '[email protected]' : '[email protected]'))
->to(new Address('[email protected]'))
->subject($isSandbox ? '[SANDBOX] Demo email' : 'Welcome onboard')
->text('This is a minimal body for demonstration purposes.');
$response = $client->send($email);
// Access response body as array (helper optional)
var_dump(ResponseHelper::toArray($response));