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

Sendinblue Mailer Laravel Package

symfony/sendinblue-mailer

Symfony Mailer bridge for Sendinblue (Brevo). Provides a transport to send emails through the Sendinblue API while using Symfony Mailer features and configuration, integrating easily into Symfony apps for transactional and marketing email delivery.

Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install the Package

    composer require symfony/mailer symfony/sendinblue-mailer
    

    (Note: symfony/mailer is a dependency, so install both.)

  2. Configure in config/mail.php Add Sendinblue as a transport in Laravel’s mail config:

    'transports' => [
        'sendinblue' => [
            'dsn' => 'sendinblue://default:your_sendinblue_api_key@default',
        ],
    ],
    

    (Replace your_sendinblue_api_key with your actual API key from Sendinblue.)

  3. Set Default Transport In .env:

    MAIL_MAILER=sendinblue
    
  4. First Test Email

    use Illuminate\Support\Facades\Mail;
    
    Mail::send([], [], function ($message) {
        $message->to('recipient@example.com')
                ->subject('Test Email')
                ->text('Hello from Laravel + Sendinblue!');
    });
    

Where to Look First


Implementation Patterns

1. Sending Emails

Basic Email

Mail::to('user@example.com')->send(new OrderShipped($order));

(Use Laravel’s Mailable classes for structured emails.)

Async Sending (Queue)

Mail::to('user@example.com')->later(now()->addMinutes(5))->send(new WelcomeEmail());

(Requires MAIL_MAILER=sendinblue + queue driver configured.)

Attachments & Embeds

$message = (new OrderShipped($order))->to('user@example.com');
$message->attach(storage_path('app/invoice.pdf'));
$message->embed(storage_path('app/logo.png'), 'logo_id');

2. Templates & Personalization

Using Blade Templates

Mail::send('emails.welcome', ['user' => $user], function ($message) {
    $message->to($user->email)->subject('Welcome!');
});

Markdown Emails

Mail::markdown('emails.notification', ['data' => $data])
    ->to($user->email)
    ->subject('Your Notification');

Dynamic Recipients

$recipients = ['user1@example.com', 'user2@example.com'];
Mail::to($recipients)->send(new Newsletter());

3. Transactional Emails (Sendinblue-Specific)

Using Sendinblue Templates

$message = (new OrderConfirmation($order))->to('user@example.com');
$message->sendinblueTemplateId(12345); // Your Sendinblue template ID

Tracking & Analytics

Sendinblue automatically tracks opens/clicks. Access data via:

  • Sendinblue Dashboard (link)
  • Webhooks (Configure in Sendinblue → Settings → Webhooks)

4. Integration with Laravel Events

// In an Event Listener
public function handle(UserRegistered $event) {
    Mail::to($event->user->email)->send(new WelcomeEmail($event->user));
}

5. Testing

Mocking in Tests

public function test_welcome_email() {
    Mail::fake();

    $this->actingAs($user)
         ->post('/register');

    Mail::assertSent(WelcomeEmail::class);
}

Using Sendinblue Sandbox

  • Enable Sandbox Mode in Sendinblue settings.
  • Use a dedicated test API key in .env:
    SENDINBLUE_API_KEY=sandbox_key_here
    

Gotchas and Tips

Pitfalls

  1. API Key Exposure

    • Never commit .env to version control.
    • Use Laravel’s .env or environment variables securely.
  2. Rate Limits

    • Sendinblue has rate limits (e.g., 9,000 emails/day for free tier).
    • Queue emails during peak times to avoid throttling.
  3. Template Mismatches

    • Ensure sendinblueTemplateId matches your Sendinblue template ID.
    • Debug with dd($message->getSendinblueTemplateId()).
  4. Async Delays

    • Emails sent via queues may delay if the queue worker is down.
    • Monitor failed_jobs table for stuck emails.
  5. HTML vs. Text Parts

    • Sendinblue prefers HTML emails. Ensure your Mailable includes both:
      public function build() {
          $this->subject('Hello')
               ->html('view.welcome')
               ->text('plain.welcome');
      }
      

Debugging Tips

  1. Check Raw Message

    $message = (new WelcomeEmail())->to('user@example.com');
    dd($message->getSymfonyMessage()->toString());
    
  2. Enable Symfony Mailer Debug

    // In a test or debug route
    $mailer = app(\Symfony\Component\Mailer\Mailer::class);
    $mailer->getTransport()->getLogger()->setLevel(\Psr\Log\LogLevel::DEBUG);
    
  3. Sendinblue API Errors

    • Check response in failed_jobs table for exception field.
    • Common errors:
      • 401 Unauthorized: Invalid API key.
      • 400 Bad Request: Invalid template ID or recipient.

Extension Points

  1. Custom Transport Extend Symfony’s Transport for custom logic:

    use Symfony\Component\Mailer\Transport\AbstractTransport;
    
    class CustomSendinblueTransport extends AbstractTransport {
        protected function doSend(Swift_Mime_SimpleMessage $message) {
            // Custom logic (e.g., retry failed sends)
        }
    }
    
  2. Webhook Handling Use Laravel’s route:webhook to handle Sendinblue events (e.g., email opens):

    Route::post('/sendinblue/webhook', function (Request $request) {
        // Validate and process webhook payload
    });
    
  3. Bulk Emails For large campaigns, use Sendinblue’s SMTP Relay or their Transactional API directly.

Config Quirks

  1. DSN Format

    • Correct format: sendinblue://api_key@default
    • Avoid extra spaces or special characters.
  2. Default vs. Custom Transports

    • Use mailer key in .env to switch between transports dynamically:
      MAIL_MAILER=sendinblue
      MAIL_SENDINBLUE_TRANSPORT=custom_sendinblue
      
  3. SSL/TLS

    • Sendinblue uses TLS by default. No need to configure SSL unless using a self-signed cert.

Pro Tips

  1. Use Laravel Notifications Combine with Illuminate\Notifications for unified email/SMS logic:

    $user->notify(new WelcomeNotification());
    
  2. Localization Support multiple languages in emails:

    $message->subject(__('Welcome!'));
    $message->markdown('emails.welcome', ['user' => $user], fn ($m) => $m->locale($user->locale));
    
  3. Monitor with Laravel Horizon Track email queue performance:

    php artisan horizon
    
  4. Sendinblue SMTP Fallback If using SMTP, ensure your Laravel mail.php has:

    'sendinblue' => [
        'transport' => 'smtp',
        'host' => 'smtp.sendinblue.com',
        'port' => 587,
        'encryption' => 'tls',
        'auth_mode' => 'login',
        'username' => 'your@email.com',
        'password' => 'your_sendinblue_smtp_password',
    ],
    
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport