定制 hexters/maillens 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

hexters/maillens

Composer 安装命令:

composer require hexters/maillens

包简介

Catch outgoing mail during local development and read it in the browser at /mail. Set MAIL_MAILER=lens and every email your Laravel app sends is stored instead of delivered.

README 文档

README

MailLens

MailLens

Latest Stable Version Total Downloads Tests License

MailLens catches the email your app sends while you are developing, so you can read it in the browser instead of wiring up a real inbox. Set one env variable and every message your Laravel app tries to send gets saved and shown at /mail. There is nothing to install outside Composer, no Docker, and no SMTP catcher running in the background.

If you have used Mailtrap or Mailpit before, it is the same idea, except it lives inside your own app.

Requirements

  • PHP 8.1 or newer
  • Laravel 10, 11, 12, or 13

Install

composer require hexters/maillens --dev

The service provider registers itself. Set the mailer in your .env:

MAIL_MAILER=lens

Then run the migration to create the table MailLens stores mail in:

php artisan migrate

Set MAIL_MAILER=lens before you migrate. The migration only loads while that mailer is active, so running migrate first would skip it and the table would not be created.

Now send mail the way you normally would and open /mail to read it. You do not need to touch config/mail.php; MailLens adds the lens mailer for you.

How it works

Setting MAIL_MAILER=lens sends your mail through a transport that stores the message instead of delivering it. It keeps the subject, the sender and recipients, the HTML and text bodies, any attachments, and the raw source. The /mail page puts the message list on one side and the selected message on the other, with tabs for HTML, plain text, and source, plus links to download any attachments.

Queued mail

MailLens only changes where your mail ends up, not how your queue works. If a mailable is queued (ShouldQueue, Mail::queue(), or a queued notification), it shows up in /mail after the queue runs the job, the same as it would before a real send:

  • QUEUE_CONNECTION=database: run a worker with php artisan queue:work
  • QUEUE_CONNECTION=redis: run your worker, or Horizon if that is your setup
  • QUEUE_CONNECTION=sync: nothing to run, the mail is captured right away

So if a queued email never shows up, check that a worker is running before you blame MailLens.

Turning it off

There is no separate switch. MAIL_MAILER is the switch. When it is set to anything other than lens, MailLens stays quiet: it does not register the /mail route, it does not load its migration, and nothing routes through it. Keep MAIL_MAILER=lens out of your production .env and your mail will send for real there.

Configuration

Most people never need this, but you can publish the config file to change the defaults:

php artisan vendor:publish --tag=maillens-config
MAILLENS_ROUTE_PREFIX=mail  # the inbox lives here
MAILLENS_LIMIT=200          # how many messages to keep (null keeps all of them)

Captured mail is saved on your app's default database connection.

Contributing

Bug reports and pull requests are welcome. Have a look at CONTRIBUTING.md first.

License

MIT. See LICENSE.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固