shaffe/laravel-dkim 问题修复 & 功能扩展

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

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

shaffe/laravel-dkim

Composer 安装命令:

composer require shaffe/laravel-dkim

包简介

Laravel package to add DKIM signatures to outgoing emails

README 文档

README

A drop-in Laravel package that automatically signs all outgoing emails with DKIM. No changes to your existing Mailables, Notifications, or any mail-sending code required — just install, configure your key, and every email gets signed transparently.

Uses Symfony's built-in DkimSigner under the hood.

Installation

composer require shaffe/laravel-dkim

The service provider is auto-discovered via the composer.json extra configuration.

Configuration

Publish the config file:

php artisan vendor:publish --tag=dkim-config

Add these variables to your .env:

DKIM_ENABLED=true
DKIM_PRIVATE_KEY=/path/to/your/private.key
DKIM_DOMAIN=example.com
DKIM_SELECTOR=my-selector
DKIM_PASSPHRASE=

DKIM_PRIVATE_KEY accepts either a path to a PEM key file or the raw PEM key as a string.

Choosing a Selector

We recommend using a custom selector instead of default. The default DKIM key (default._domainkey.example.com) is often managed by your hosting panel (Plesk, cPanel, etc.) and may be regenerated during system upgrades or configuration changes — which would silently break your application's DKIM signing.

Using a dedicated selector like laravel, or app-mail gives you several advantages:

  • Your key is independent from the system-managed one and won't be affected by server-side changes.
  • It clearly identifies the source of signed emails (useful when multiple services send from the same domain).
  • You can rotate or revoke the key without impacting other services.

Key Generation

Generate a dedicated key pair for your selector:

openssl genrsa -out my-selector.dkim.private 2048
openssl rsa -in my-selector.dkim.private -out my-selector.dkim.public -pubout -outform PEM

DNS Setup

Add a TXT record for your selector on the sending domain:

my-selector._domainkey.example.com  IN  TXT  "v=DKIM1; k=rsa; s=email; p=<your_public_key_base64>"

The p= value is the content of your public key file, without the -----BEGIN/END PUBLIC KEY----- lines and without line breaks.

Verifying Your DNS Record

You can verify that your DKIM DNS record is correctly set up using MXToolbox:

https://mxtoolbox.com/SuperTool.aspx?action=dkim:example.com:my-selector&run=toolpage

Replace example.com with your domain and my-selector with your chosen selector.

How It Works

The package hooks into Laravel's mail pipeline by listening to \Illuminate\Mail\Events\MessageSending. This event fires right before any email is handed off to the transport, so every email sent through Laravel's mailer (Mailables, Notifications, Mail::raw(), etc.) is automatically signed — without touching a single line of your existing code.

shaffe/laravel-dkim 适用场景与选型建议

shaffe/laravel-dkim 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 409 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 shaffe/laravel-dkim 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 shaffe/laravel-dkim 我们能提供哪些服务?
定制开发 / 二次开发

基于 shaffe/laravel-dkim 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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