Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Elasticemail Mailer Laravel Package

bertoost/elasticemail-mailer

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package via Composer:

composer require bertoost/elasticemail-mailer

Publish the config file (if needed) for customization:

php artisan vendor:publish --provider="Bertoost\ElasticEmail\ElasticEmailServiceProvider"

Register the mailer in config/mail.php under the mailers array:

'elasticemail' => [
    'transport' => 'elasticemail',
],

Use the mailer in your application by injecting ElasticEmailMailer or using the Mail facade:

use Illuminate\Support\Facades\Mail;

Mail::mailer('elasticemail')->send(new YourMailClass());

Implementation Patterns

Basic Usage

Configure the ElasticEmail API key in .env:

ELASTICEMAIL_API_KEY=your_api_key_here

Send emails via the Mail facade or directly:

Mail::to('recipient@example.com')->send(new YourMailClass());

Or using the mailer directly:

$mailer = app('mailer.elasticemail');
$mailer->send(new YourMailClass());

Symfony Integration

Ensure Symfony's HttpClient is installed (if not auto-resolved):

composer require symfony/http-client

The package now supports Symfony's HttpClient integration for better HTTP handling. No additional config is required if using Laravel's default HTTP client.

PHP 8.4 Compatibility

The package now fully supports PHP 8.4. No changes are required for existing projects, but ensure your Laravel version is compatible (Laravel 10+ recommended).


Gotchas and Tips

Symfony Integration Fix

If you encounter issues with Symfony's HttpClient (e.g., timeouts or malformed responses), explicitly bind the client in your AppServiceProvider:

use Symfony\Component\HttpClient\HttpClient;

public function register()
{
    $this->app->singleton(\Symfony\Contracts\HttpClient\HttpClientInterface::class, function () {
        return HttpClient::create();
    });
}

Debugging API Issues

Enable verbose logging for ElasticEmail API calls by setting:

ELASTICEMAIL_LOG_LEVEL=debug

Check logs in storage/logs/laravel.log for detailed API responses.

API Key Security

Never hardcode API keys in your codebase. Use Laravel's .env file and restrict file permissions:

chmod 600 .env

Extension Points

Extend the mailer behavior by binding your own ElasticEmailClient implementation:

$this->app->bind(\Bertoost\ElasticEmail\Contracts\ElasticEmailClient::class, function () {
    return new YourCustomElasticEmailClient();
});

PHP 8.4 Deprecation Note

If upgrading from PHP <8.4, ensure your codebase uses type-safe methods (e.g., array_key_first instead of reset). The package handles its own deprecations, but dependent code may need updates.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui