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 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 withphp artisan queue:workQUEUE_CONNECTION=redis: run your worker, or Horizon if that is your setupQUEUE_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
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-01
