Integrations

Laravel

Mailtrap bridge for Laravel, providing native integration with the Laravel mail system.

How it works

Integrate Mailtrap directly into your Laravel application using our dedicated driver. This allows you to use Mailtrap as a mailer for all your app’s communications, from Notifications to Mailables, without changing your workflow. Swap between sandbox and sending with a simple configuration change and get industry-best deliverability.

Configure

Step 1: Create a Mailtrap account, verify your domain, and get the API token.

Step 2: For a quick start, run one of the following commands ⬇️

# With symfony http client (recommend)
composer require railsware/mailtrap-php symfony/http-client nyholm/psr7 symfony/mailer

# Or with guzzle http client
composer require railsware/mailtrap-php guzzlehttp/guzzle php-http/guzzle7-adapter symfony/mailer

Step 3: Add mailtrap transport into your config/mail.php file.

<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Mailer Configurations
    |--------------------------------------------------------------------------
    */
    'mailers' => [
   
            // start mailtrap transport
            'mailtrap-sdk' => [
                'transport' => 'mailtrap-sdk'
            ],
            // end mailtrap transport
   
    ]
];

Set mailtrap-sdk transport as a default Laravel mailer and change default mailtrap config variables inside your .env file.

Step 4: Set the API key to the MAILTRAP_API_KEY variable.

Step 5: Generate Mailable class with the following command. 

php artisan make:mail WelcomeMail

Step 6: Configure and send your emails – hit the link to see an example. 

For more details and examples, check the official docs for Mailtrap Laravel Bridge

Supported functionality

  • Email sending – transitional and bulk 
  • Batch sending
  • Contacts and contacts lists management
  • Templates management 
  • Sending domains management
  • Sending and getting sandbox emails
  • Managing sandbox projects