letmesendemail / letmesendemail-laravel
LetMeSendEmail Laravel Plugin
Package info
github.com/apsonex/letmesendemail-laravel
pkg:composer/letmesendemail/letmesendemail-laravel
Requires
- php: ^8.2
- illuminate/http: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- letmesendemail/letmesendemail-php: ^1.0
- symfony/mailer: ^6.2|^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.94
- orchestra/testbench: ^10.9
- pestphp/pest: ^3.8
- pestphp/pest-plugin-laravel: ^3.2
- phpunit/phpunit: ^11.5
This package is auto-updated.
Last update: 2026-03-16 14:00:09 UTC
README
Official Laravel integration for LetMeSendEmail, a modern email API service. This package provides:
- Full Laravel SDK for LetMeSendEmail
- Symfony Mailer transport
- Webhook handling with signature verification
- Facade for convenient API access
- Event dispatching for all email lifecycle events
- Testing utilities with fake responses
For more details about the core API, visit letmesendemail-php GitHub.
Table of Contents
Installation
Install via Composer:
composer require letmesendemail/letmesendemail-laravel
Laravel will automatically register the service provider via package discovery.
Configuration
Publish the configuration file:
php artisan vendor:publish --provider="LetMeSendEmail\Laravel\LetMeSendEmailServiceProvider" --tag="config"
Add your API key and webhook secret to .env:
LMSE_API_KEY=your_api_key_here LMSE_WEBHOOK_SECRET=whsec_your_webhook_secret
Usage
Facade
Access LetMeSendEmail API via the facade:
use LetMeSendEmail\Laravel\Facades\LetMeSendEmail; // Send an email $response = LetMeSendEmail::emails()->send([ 'from' => 'hello@yourdomain.com', 'to' => 'recipient@example.com', 'subject' => 'Hello!', 'text' => 'This is a test email.', ]); // Access other resources $domains = LetMeSendEmail::domains(); $contacts = LetMeSendEmail::contacts(); $categories = LetMeSendEmail::contactCategories(); $tags = LetMeSendEmail::contactTags();
Fake responses for testing:
LetMeSendEmail::fake('emails/send');
Visit composer vendor directory vendor/letmesendemail/letmesendemail-php/tests/Fixtures for available fake responses.
Sending Emails via Symfony Mailer
Configure the transport in config/mail.php:
'mailers' => [ 'letmesendemail' => [ 'transport' => 'letmesendemail', ], ],
Send an email:
use Illuminate\Support\Facades\Mail; use Symfony\Component\Mime\Email; $email = (new Email()) ->from('hello@yourdomain.com') ->to('recipient@example.com') ->subject('Hello') ->text('This is a test email') ->html('<p>This is a test email</p>'); Mail::mailer('letmesendemail')->send($email);
Supports attachments and headers:
$email->attach('File contents', 'filename.txt', 'text/plain'); $email->getHeaders()->addTextHeader('X-Custom-Header', 'value');
Webhooks
Controller Setup
The package provides a webhook controller:
use LetMeSendEmail\Laravel\Http\Controllers\WebhookController; Route::post('/letmesendemail/webhook', [WebhookController::class, 'handleWebhook']);
This controller dispatches events based on the webhook type.
Middleware Verification
If you set webhook.secret in the config, the VerifyWebhookSignature middleware validates the signature automatically:
use LetMeSendEmail\Laravel\Http\Middleware\VerifyWebhookSignature; Route::post('/letmesendemail/webhook', [WebhookController::class, 'handleWebhook']) ->middleware(VerifyWebhookSignature::class);
The middleware will reject requests with invalid or missing signatures with a 401 Unauthorized.
Events
The following events are dispatched for webhooks:
EmailSentEmailDeliveredEmailDeliveryDelayedEmailComplainedEmailBouncedEmailOpenedEmailClickedEmailReceivedEmailRejectedEmailFailedEmailScanFailedEmailRenderingFailure
Example usage:
use LetMeSendEmail\Laravel\Events\EmailSent; use Illuminate\Support\Facades\Event; Event::listen(EmailSent::class, function ($event) { logger()->info('Email sent:', $event->payload); });
Exceptions
MissingApiKeyException— thrown if the API key is not set.WebhookSigningException— thrown for invalid webhook signature generation.WebhookVerificationException— thrown for failed webhook verification.
Testing & Fake Responses
You can fake API responses in tests:
LetMeSendEmail::fake('emails/send');
Example Pest test:
it('resolves_letmesendemail_client', function () { config(['letmesendemail.key' => 'test']); expect(LetMeSendEmail::getFacadeRoot())->toBeInstanceOf(\LetMeSendEmail\Client::class); });
Contributing
Contributions are welcome! Please fork the repository, make your changes, and submit a pull request.
License
This package is licensed under the MIT License.