tomahock/laravel-cloudflare-mail 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tomahock/laravel-cloudflare-mail

最新稳定版本:v1.0.2

Composer 安装命令:

composer require tomahock/laravel-cloudflare-mail

包简介

Laravel mail driver for Cloudflare Email Service

README 文档

README

A Laravel mail transport driver for Cloudflare Email Service.

Note: Cloudflare Email Service is currently in beta. Ensure your account has access before using this package.

Requirements

  • PHP 8.1+
  • Laravel 10, 11, or 12

Installation

composer require tomahock/laravel-cloudflare-mail

Publish the config file:

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

Configuration

Add the following variables to your .env file:

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

Configure the mailer in config/mail.php:

'mailers' => [
    'cloudflare' => [
        'transport' => 'cloudflare',
    ],
],

Set it as the default mailer:

MAIL_MAILER=cloudflare

Usage

Use Laravel's standard Mail facade — no API-specific code required:

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

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

Or with a raw message:

Mail::raw('Hello World', function ($message) {
    $message->to('recipient@example.com')
            ->from('sender@yourdomain.com', 'Your App')
            ->subject('Hello');
});

Setting Up Cloudflare Email Sending

Before sending emails, you must configure the Cloudflare Email Sending service in your account:

  1. Go to Cloudflare Dashboard and select your account
  2. Navigate to EmailEmail Sending (currently in beta — you may need to request access)
  3. Add your sender domain (e.g. yourdomain.com) and follow the DNS verification steps
  4. Add the required DNS records (SPF, DKIM) that Cloudflare provides for your domain

Note: Attempting to send emails before the domain is verified will result in a 500 Internal Server Error from the API (email.sending.error.internal_server).

Creating API Tokens

  1. Go to Cloudflare DashboardMy ProfileAPI Tokens
  2. Create a token with Email Service: Send permission scoped to your account
  3. Copy the token into CLOUDFLARE_API_TOKEN

Your CLOUDFLARE_ACCOUNT_ID is visible in the URL when logged into the Cloudflare dashboard (dash.cloudflare.com/{account_id}/...) or under Account Home → Overview.

Supported Features

Feature Supported
Plain text body
HTML body
CC / BCC
Reply-To
Named addresses ("Name" <email>)
File attachments
Multiple recipients

Running Tests

composer install
vendor/bin/phpunit

License

MIT

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固