Product Decisions This Supports
- Incident Response & Observability: Automatically capture and notify teams about uncaught exceptions in Laravel applications, reducing mean time to resolution (MTTR) for critical failures. Aligns with SRE principles by shifting from reactive debugging to proactive alerts.
- Developer Experience (DevEx): Eliminate manual log checks by surfacing exceptions via email with contextual data (stack traces, request details), improving debugging efficiency. Supports blameless postmortems by providing clear error documentation.
- Build vs. Buy: Avoid reinventing a custom exception-notification system (e.g., writing cron jobs, log parsers, or third-party integrations like Sentry). This package offers a low-code, high-impact solution for teams without dedicated observability budgets.
- Multi-Environment Strategy: Gradually roll out monitoring by excluding
local/staging environments while capturing production issues, aligning with progressive delivery and feature flags best practices.
- Compliance & Auditing: Log exceptions to email for non-technical stakeholders (e.g., legal, security teams) who need evidence of system failures without direct access to logs or dashboards.
- Roadmap Prioritization: Justify investing in dedicated monitoring tools (e.g., Sentry, Datadog) by first implementing this as a zero-cost, high-impact stopgap for critical exceptions. Use metrics (e.g., "X% reduction in unnoticed errors") to advocate for future tooling.
- Legacy System Modernization: Ideal for Symfony/Laravel hybrid apps or legacy Laravel 5.x projects where upgrading to modern observability tools is costly. Provides a bridge to future-proof monitoring.
When to Consider This Package
Adopt If:
- Running a Laravel 5.x–8.x app with minimal or no existing error monitoring.
- Need zero-config, immediate exception alerts for production (e.g., small teams, startups, or internal tools).
- Exceptions are infrequent and critical (e.g., payment failures, API timeouts) where email alerts justify the signal-to-noise ratio.
- Team lacks budget/time for custom solutions or third-party tools (e.g., Sentry’s free tier has limits).
- Symfony compatibility is a hard requirement (e.g., legacy microservices or hybrid stacks).
- Want to avoid external dependencies (e.g., no APIs, databases, or SaaS tools).
Look Elsewhere If:
- Advanced Alerting Needed: Require escalation policies (e.g., Slack/Teams alerts, on-call rotations), multi-channel notifications, or downtime tracking. Use PagerDuty, Opsgenie, or Sentry.
- High-Volume Environments: Expecting >50 exceptions/hour; email may become noisy or trigger spam filters. Use Sentry, Rollbar, or Datadog.
- Sensitive Data Handling: Exceptions may contain PII, tokens, or stack traces with secrets. This package lacks redaction or encryption; use Sentry’s
beforeSend or custom sanitization.
- Laravel 9+ or PHP 8.1+: The original bundle is unmaintained (2016) and may not support newer Laravel versions. Fork or build a custom version using Laravel’s
ExceptionHandler.
- Non-Email Alerts: Need SMS, push notifications, or dashboard integrations. Pair with Laravel Notifications or third-party services.
- Custom Exception Logic: Require dynamic filtering (e.g., ignore exceptions based on user roles, request paths, or business logic). This package’s
avoid config is static; extend with Laravel’s report() method.
- Performance-Critical Apps: Email delivery adds latency; critical exceptions should trigger synchronous alerts (e.g., HTTP webhooks) alongside async emails.
- Existing Monitoring Stack: Already using Sentry, Bugsnag, or Laravel Telescope. This package is redundant unless used as a fallback.
How to Pitch It (Stakeholders)
For Executives:
*"This package turns Laravel errors into automated email alerts—no extra tools, no setup hassle. For zero cost, we’ll catch production failures before users report them, cutting downtime by [X]% and saving [Y] hours/week in debugging. It’s like having a 24/7 ops assistant for critical bugs, with no upfront investment.
Why Now?
- Low Risk: 5-minute setup, no dependencies.
- High Impact: Catches unhandled exceptions that logs miss (e.g., silent failures in queues).
- Scalable: Start here, then add Sentry/Datadog later if needed.
ROI:
- Time Saved: Developers spend [Z]% less time hunting for errors.
- Cost Avoidance: Avoids [$A/month] for third-party tools until we’re ready to scale.
- User Trust: Reduces customer-reported bugs by [B]%.
Next Step: Let’s enable this in staging for 2 weeks and measure the impact."*
For Engineering Teams:
*"This package automates exception alerts via email—here’s how to use it in Laravel:
Why It’s Worth Trying:
- No Dependencies: Uses Laravel’s built-in
ExceptionHandler and Mail facade.
- Configurable: Ignore
local/staging environments and specific exceptions (e.g., 404s).
- Extensible: Want Slack alerts later? Start here and bolt on integrations.
- Battle-Tested: Used in [X] legacy Laravel apps to catch critical bugs before users report them.
How to Implement:
- Option 1 (Quick): Extend
App\Exceptions\Handler to send emails on uncaught exceptions.
public function report(Throwable $exception) {
if (!$this->shouldSend($exception)) return;
Mail::to(config('mail-exception.to'))
->send(new ExceptionEmail($exception));
}
- Option 2 (Advanced): Fork the original bundle and adapt it for Laravel (Symfony → Laravel event mapping).
Trade-offs:
- Not for high-volume alerts (email spam risk).
- No real-time dashboards (but great for async debugging).
- Unmaintained, but trivial to fork if needed.
Proposal: Let’s enable this in production for a week and see what we catch!"*
For Developers:
*"This package hooks into Laravel’s exception handler to email you when bugs slip through. How it works:
Setup (5 minutes):
- Install:
composer require desarrolla2/mail-exception-bundle
- OR (recommended for Laravel):
Extend
App\Exceptions\Handler to send emails:
use Illuminate\Support\Facades\Mail;
use App\Mail\ExceptionEmail;
public function report(Throwable $exception) {
if (app()->environment(['local', 'staging'])) return;
Mail::to('team@company.com')->send(new ExceptionEmail($exception));
}
- Create a mailable:
php artisan make:mail ExceptionEmail
What You’ll Get:
![Example email with stack trace, request data, and environment context]
Why It’s Useful:
- No more ‘Did that 500 error happen?’—you’ll know instantly.
- Includes request data (URL, headers, POST body) for faster debugging.
- Works out of the box with zero runtime overhead in production.
Gotchas:
- Only works for unhandled exceptions (wrapped in
try/catch? You’re out of luck).
- No rate limiting—spammy if your app throws exceptions frequently.
- Symfony-based, but we can adapt it for Laravel (see above).
Next Steps:
- Enable in staging and test with a forced error (
throw new Exception('Test')).
- Configure
avoid rules in .env (e.g., ignore 404 errors).
- Extend it: Add Slack alerts or database logging later!
Example .env:
MAIL_EXCEPTION_TO=team@example.com
MAIL_EXCEPTION_AVOID_EXCEPTIONS=Symfony\Component\HttpKernel\Exception\NotFoundHttpException
MAIL_EXCEPTION_AVOID_ENVIRONMENTS=local,staging
```"
---
### **For Security/Compliance Teams**:
*"This package **logs exceptions to email** for auditing and incident response. **Key benefits**:
- **Non-Technical Access**: Stakeholders (e.g., legal, security) get **structured error reports** without log access.
- **Compliance Evidence**: Emails serve as **timestamped records** of failures (e.g., for PCI/DSPA audits).
- **No Data Leaks**: By default, emails include **only exception details** (no sensitive data). Customize the mailable to exclude PII.