A custom Laravel mail transport driver to send emails via the Postal mail server using its HTTP API instead of SMTP. Official documentation: https://apiv1.postalserver.io/controllers/send/message.html
- Send transactional emails via Postal HTTP API
- Uses Laravel's native
Mail::to()->send()
interface - Clean, framework-native mail transport driver
- Compatible with Laravel version 8.0+
If using local development:
composer require php-monsters/laravel-postal-driver
Or add to your composer.json:
"repositories": [
{
"type": "path",
"url": "./packages/PhpMonsters/LaravelPostalDriver"
}
],
"require": {
"php-monsters/laravel-postal-driver": "*"
}
Then run:
composer update
MAIL_MAILER=postal
POSTAL_API_KEY=your_postal_api_key_here
POSTAL_API_ENDPOINT=https://postal.yourdomain.com
Add to the mailers array:
'mailers' => [
'postal' => [
'transport' => 'postal',
'key' => env('POSTAL_API_KEY'),
'endpoint' => env('POSTAL_API_ENDPOINT'),
],
],
Use Laravel's standard Mail facade:
use App\Mail\TestMail;
use Illuminate\Support\Facades\Mail;
Mail::to('[email protected]')->send(new TestMail());
Your Mailable class should work as usual.
This driver makes HTTP POST requests to:
POST /api/v1/send/message
With headers:
X-Server-API-Key: {your_api_key}
Content-Type: application/json
Payload:
{
"to": "[email protected]",
"from": "[email protected]",
"subject": "Subject Line",
"plain_body": "Text version",
"html_body": "<p>HTML version</p>"
}
- Laravel 8 or newer
- Postal mail server with API access
- PHP 8.0+
- Guzzle 7+
This project is open-sourced under the MIT license.
Made with ❤️ by Aboozar Ghaffari
Postal by Atech Media