PHPackages                             noneym/laravel10-cloudflare-mail - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. noneym/laravel10-cloudflare-mail

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

noneym/laravel10-cloudflare-mail
================================

Cloudflare Email Service (REST API) transport for Laravel 10, 11 and 12 — PHP 8.2 &amp; 8.3 compatible.

0138↓100%PHP

Since Apr 21Pushed 1mo agoCompare

[ Source](https://github.com/noneym/laravel10-cloudflare-mail)[ Packagist](https://packagist.org/packages/noneym/laravel10-cloudflare-mail)[ RSS](/packages/noneym-laravel10-cloudflare-mail/feed)WikiDiscussions init Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Cloudflare Mail (Laravel 10+ / PHP 8.2 &amp; 8.3)
=========================================================

[](#laravel-cloudflare-mail-laravel-10--php-82--83)

A Laravel mail transport for the **Cloudflare Email Service REST API**, compatible with **Laravel 10, 11, and 12** and **PHP 8.2 / 8.3**.

Inspired by [`toitzi/laravel-cloudflare-mail`](https://github.com/toitzi/laravel-cloudflare-mail), rewritten to drop the PHP 8.4 / Laravel 12-only requirement so it runs on older Laravel 10 codebases.

Requirements
------------

[](#requirements)

PackageVersionPHP`^8.2` (tested on 8.2 and 8.3)Laravel`^10.0 || ^11.0 || ^12.0`Symfony Mailer`^6.2 || ^7.0` (ships with Laravel)You also need:

- A Cloudflare **Account ID**
- A Cloudflare **API token** with the **Email Sending** permission
- A domain onboarded to Cloudflare Email Service (DNS verified)

Installation
------------

[](#installation)

```
composer require noneym/laravel10-cloudflare-mail
```

The service provider is auto-discovered.

Configuration
-------------

[](#configuration)

### `.env`

[](#env)

```
MAIL_MAILER=cloudflare

CLOUDFLARE_EMAIL_ACCOUNT_ID=your_cloudflare_account_id
CLOUDFLARE_EMAIL_API_TOKEN=your_api_token_with_email_sending_permission
# Optional override:
CLOUDFLARE_EMAIL_BASE_URL=https://api.cloudflare.com/client/v4

MAIL_FROM_ADDRESS=noreply@yourdomain.com
MAIL_FROM_NAME="Your App"
```

### `config/mail.php`

[](#configmailphp)

Add a `cloudflare` mailer entry:

```
'default' => env('MAIL_MAILER', 'cloudflare'),

'mailers' => [

    // ... your other mailers

    'cloudflare' => [
        'transport'       => 'cloudflare',
        'account_id'      => env('CLOUDFLARE_EMAIL_ACCOUNT_ID'),
        'api_token'       => env('CLOUDFLARE_EMAIL_API_TOKEN'),
        'base_url'        => env('CLOUDFLARE_EMAIL_BASE_URL', 'https://api.cloudflare.com/client/v4'),
        'timeout'         => 30,
        'connect_timeout' => 10,
    ],

],
```

That's it — Laravel's Mail facade, Mailable classes, notifications, and queued mail all work as-is.

Usage
-----

[](#usage)

### Quick send

[](#quick-send)

```
use Illuminate\Support\Facades\Mail;

Mail::raw('Hello from Cloudflare!', function ($message) {
    $message->to('user@example.com')->subject('Welcome');
});
```

### Mailable

[](#mailable)

```
Mail::to($user)->send(new \App\Mail\WelcomeMail($user));
```

### Notifications

[](#notifications)

```
// in Notification class
public function via($notifiable)
{
    return ['mail'];
}
```

Nothing else changes — Laravel routes it through the `cloudflare` transport automatically.

What's supported
----------------

[](#whats-supported)

- HTML and plain-text bodies
- `to`, `cc`, `bcc`
- Single `from` and single `reply_to`
- Regular file attachments (base64-encoded)
- Custom headers (except headers reserved by Cloudflare)

Cloudflare REST API limitations
-------------------------------

[](#cloudflare-rest-api-limitations)

These are Cloudflare limits, not package limits:

- Only **one** `from` address per request
- Only **one** `reply_to` address per request
- **Inline attachments are not supported** and will throw a `CloudflareTransportException`
- The `from` address **must be on a domain that is verified** in Cloudflare Email Service
- Daily send quota applies (e.g. 1000/day on the free tier)

Error handling
--------------

[](#error-handling)

Failures raise `Noneym\LaravelCloudflareMail\Exceptions\CloudflareTransportException`, which includes the HTTP status code and the Cloudflare error payload when available.

```
use Noneym\LaravelCloudflareMail\Exceptions\CloudflareTransportException;

try {
    Mail::to('user@example.com')->send(new WelcomeMail());
} catch (CloudflareTransportException $e) {
    report($e);
}
```

Testing the package itself
--------------------------

[](#testing-the-package-itself)

```
composer install
composer test
```

Security
--------

[](#security)

Never commit your Cloudflare API token. Keep it in `.env` and rotate it via the Cloudflare dashboard if exposed.

Credits
-------

[](#credits)

- Original inspiration: [`toitzi/laravel-cloudflare-mail`](https://github.com/toitzi/laravel-cloudflare-mail) by Tobias Oitzinger
- Cloudflare Email Service:

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance59

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/190996?v=4)[noneym](/maintainers/noneym)[@noneym](https://github.com/noneym)

---

Top Contributors

[![noneym](https://avatars.githubusercontent.com/u/190996?v=4)](https://github.com/noneym "noneym (1 commits)")

### Embed Badge

![Health badge](/badges/noneym-laravel10-cloudflare-mail/health.svg)

```
[![Health](https://phpackages.com/badges/noneym-laravel10-cloudflare-mail/health.svg)](https://phpackages.com/packages/noneym-laravel10-cloudflare-mail)
```

###  Alternatives

[mattketmo/email-checker

Throwaway email detection library

2742.1M5](/packages/mattketmo-email-checker)[ifightcrime/bootstrap-growl

Pretty simple jQuery plugin that turns standard Bootstrap alerts into 'Growl-like' notifications.

80113.0k](/packages/ifightcrime-bootstrap-growl)[sarfraznawaz2005/noty

Laravel package to incorporate noty flash notifications into laravel.

324.5k](/packages/sarfraznawaz2005-noty)[andheiberg/notify

A site notification package for laravel.

119.1k1](/packages/andheiberg-notify)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
