sohaibilyas/laravel-cloudflare-email

A Cloudflare Email Service mail transport for Laravel.

Maintainers

Package info

github.com/sohaibilyas/laravel-cloudflare-email

pkg:composer/sohaibilyas/laravel-cloudflare-email

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-07-04 13:55 UTC

This package is auto-updated.

Last update: 2026-07-04 13:57:00 UTC


README

A Laravel mail transport for sending transactional mail through Cloudflare Email Service.

Installation

composer require sohaibilyas/laravel-cloudflare-email

Configuration

Enable Email Sending for your domain in Cloudflare, then add your account ID and API token to .env:

CLOUDFLARE_ACCOUNT_ID=your-account-id
CLOUDFLARE_EMAIL_TOKEN=your-api-token

You may also pass the full authorization header value:

CLOUDFLARE_EMAIL_TOKEN="Bearer your-api-token"

The package automatically registers a cloudflare-email Laravel mailer. Set it as your default mailer:

MAIL_MAILER=cloudflare-email
MAIL_FROM_ADDRESS=noreply@example.com
MAIL_FROM_NAME="${APP_NAME}"

Laravel 13 includes its own native cloudflare mail transport. This package intentionally uses cloudflare-email so it does not collide with Laravel's built-in driver. It is most useful for Laravel 11 and 12 projects where Cloudflare Email is not available by default, or for apps that want this package's explicit REST transport behavior.

Publishing the config file is optional. Use it only when you want the Cloudflare Email package config in your app:

php artisan vendor:publish --tag=cloudflare-email-config

If you prefer to configure Cloudflare Email inside Laravel's mail config instead, you may add a cloudflare-email entry to config/mail.php:

'mailers' => [
    'cloudflare-email' => [
        'transport' => 'cloudflare-email',
        'account_id' => env('CLOUDFLARE_ACCOUNT_ID'),
        'token' => env('CLOUDFLARE_EMAIL_TOKEN'),
        'timeout' => env('CLOUDFLARE_EMAIL_TIMEOUT', 30),
    ],
],

Usage

Use Laravel's mail API as usual:

use App\Mail\WelcomeMail;
use Illuminate\Support\Facades\Mail;

Mail::to('info@example.com')->send(new WelcomeMail);

The transport sends requests to:

https://api.cloudflare.com/client/v4/accounts/{account_id}/email/sending/send

Cloudflare Email Service requires the MAIL_FROM_ADDRESS domain to be enabled for Email Sending in your Cloudflare account.

Testing

composer test