#1 Laravel mail transport for Plunk with event tracking and email verification, compatible with native PHP. Works with both the official Plunk service and self-hosted instances.
- PHP 8.2+
- Laravel 10, 11, or 12
composer require marceloeatworld/plunk-laravelPublish the config file:
php artisan vendor:publish --tag="plunk-config"Add the Plunk mailer to config/mail.php:
'mailers' => [
// ... other mailers
'plunk' => [
'transport' => 'plunk',
],
],Add to your .env:
MAIL_MAILER=plunk
PLUNK_API_KEY=sk_your_secret_keyFor self-hosted Plunk:
PLUNK_API_URL=https://plunk.yourdomain.com
PLUNK_API_ENDPOINT=/api/v1/sendUse Laravel's mail system as usual -- emails are sent through Plunk automatically:
Mail::to('user@example.com')->send(new WelcomeMail());Attachments, CC, BCC, and reply-to are all supported:
Mail::to('user@example.com')
->cc('manager@example.com')
->bcc('audit@example.com')
->send(new InvoiceMail());Use the Plunk facade for direct API access:
use MarceloEatWorld\PlunkLaravel\Facades\Plunk;
// Send email directly
Plunk::sendEmail('user@example.com', 'Welcome', '<h1>Hello!</h1>', [
'from' => 'hello@yourdomain.com',
'name' => 'Your App',
'reply' => 'support@yourdomain.com',
]);
// Send with a Plunk template
Plunk::sendTemplate('user@example.com', 'tmpl_welcome', [
'name' => 'John',
'action_url' => 'https://app.example.com/verify',
]);Track events to trigger automations and segment contacts:
Plunk::trackEvent('user@example.com', 'signed_up', [
'plan' => 'pro',
'source' => 'landing_page',
]);Verify email addresses before sending:
$result = Plunk::verifyEmail('user@example.com');
if ($result['data']['valid']) {
// Email is valid
}Plunk::sendEmail(
[
'alice@example.com',
['name' => 'Bob Smith', 'email' => 'bob@example.com'],
],
'Team Update',
'<p>Hello team!</p>',
);Plunk::sendEmail('user@example.com', 'Your Invoice', '<p>Attached.</p>', [
'from' => 'billing@yourdomain.com',
'attachments' => [
[
'filename' => 'invoice.pdf',
'content' => base64_encode(file_get_contents('/path/to/invoice.pdf')),
'contentType' => 'application/pdf',
],
],
]);composer testThe MIT License (MIT). See LICENSE.md for details.