PHPackages                             mega-tj/mailer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. mega-tj/mailer

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

mega-tj/mailer
==============

A Laravel 11 package for sending emails with flexible email templates (Blade &amp; Markdown) using PHPMailer.

v1.1.2(7mo ago)0101MITPHPPHP ^8.3

Since Nov 15Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/wisedev99/mega-mailer)[ Packagist](https://packagist.org/packages/mega-tj/mailer)[ RSS](/packages/mega-tj-mailer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

Mega Mailer Version: 1.1.2 License: MIT

Mega Mailer is a simple and elegant mailer package for PHP, built on PHPMailer, and designed to integrate seamlessly with the Laravel Mailable pattern. It facilitates sending emails through SMTP with ease, offering robust support for recipients, attachments, and Blade views.

Features SMTP Support: Easily send emails using SMTP configured via Laravel's config/mailer.php.

Full Recipient Control: Dedicated methods for TO, CC, and BCC.

Attachment Support: Attach files directly via the fluent interface or through Mailable objects.

Mailable Integration: Full compatibility with Laravel's standard Mailable, Envelope, and Attachment classes.

Blade View Rendering: Send HTML emails using Laravel Blade views.

Simple API: Set recipients, subjects, and email bodies with a straightforward, fluent interface.

Installation You can install Mega Mailer via Composer. Run the following command in your project directory:

Bash

composer require mega-tj/mailer:dev-main --dev Laravel Integration

1. Register the Service Provider Ensure your package is installed via Composer. If you are using Laravel 5.5+ and have configured your composer.json for auto-discovery (as shown below), this step is automatic.

JSON

// composer.json "extra": { "laravel": { "providers": \[ "Mega\\App\\Providers\\MailerServiceProvider" \] # Mega Mailer

```
Version: 1.0.0
License: MIT

Mega Mailer is a lightweight PHP mailer package that uses PHPMailer and integrates with Laravel's Mailable pattern. It provides a small, opinionated API for sending SMTP emails, with support for recipients (TO/CC/BCC), attachments, and rendering Blade views.

## Features

- SMTP support via PHPMailer and settings from `config/mailer.php`.
- Fluent API for quick messages and first-class support for Laravel `Mailable` objects.
- TO, CC, and BCC helpers.
- Attach local files or include attachments from a `Mailable`.
- Render Blade views for HTML emails.

## Installation

Require the package with Composer (stable or dev branch):

```bash
composer require mega-tj/mailer
# or for the current development branch
composer require mega-tj/mailer:dev-main --dev
```

## Laravel integration

The package registers the service provider automatically if you rely on Composer auto-discovery. The provider class is:

```
Mega\App\Providers\MailerServiceProvider
```

### Publish configuration

To publish the package configuration to your Laravel app (creates `config/mailer.php`):

```bash
php artisan vendor:publish --provider="Mega\App\Providers\MailerServiceProvider" --tag=config
```

The package reads SMTP settings using `config('mailer.*')`.

## Configuration

The shipped configuration (`src/config/mailer.php`) exposes these keys (and defaults):

- `host` (env: MAIL_HOST) — default: `localhost`
- `port` (env: MAIL_PORT) — default: `25`
- `username` (env: MAIL_USERNAME)
- `password` (env: MAIL_PASSWORD)
- `from_address` (env: MAIL_FROM_ADDRESS) — default: `no-reply@example.com`
- `from_name` (env: MAIL_FROM_NAME) — default: `Mega Mailer`
- `smtp_auth` (env: MAIL_SMTP_AUTH) — default: `false`
- `encryption` (env: MAIL_ENCRYPTION) — `tls`, `ssl`, or `false`
- `auto_tls` (env: MAIL_AUTO_TLS) — default: `false`
- `charset` (env: MAIL_CHARSET) — default: `UTF-8`
- `smtp_options` — array of `smtp_options` passed to PHPMailer (defaults allow self-signed certs)

Set the corresponding environment variables in your `.env` file for production.

## Usage

The primary API surface is the `Mega\App\Mailer` class (PSR-4 autoloaded from `src/`). The class supports a fluent API and can also accept a Laravel `Mailable` in `send()`.

### Option 1 — Send a Laravel Mailable (recommended)

When you pass a `Mailable` instance to `send()`, the Mailer pulls subject, from, recipients, and attachments from the `Mailable`'s `envelope()` and `attachments()` methods.

```php
use Mega\App\Mailer;
use App\Mail\TestMailable;

$mailer = new Mailer();
$response = $mailer->to('recipient@example.com')
                 ->send(new TestMailable());

// $response is a string message or an error message
```

Example `Mailable` (Laravel 10+ style using `Envelope`/`Content`/`Attachment` classes):

```php
namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;

class TestMailable extends Mailable
{
    use Queueable, SerializesModels;

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Report',
            from: new Address('support@example.com', 'Support Team'),
            cc: [new Address('manager@example.com')],
            bcc: [new Address('archive@example.com')]
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.send_report',
            with: ['user' => 'John Doe']
        );
    }

    public function attachments(): array
    {
        return [
            Attachment::fromPath(storage_path('app/report.pdf'))->as('Report.pdf')
        ];
    }
}
```

### Option 2 — Fluent API (simple emails)

For quick one-off messages you can use the fluent methods. You must set the `from()` address (or configure `from_address` in `config/mailer.php`).

```php
use Mega\App\Mailer;

$mailer = new Mailer();
$mailer->from('noreply@mycompany.com', 'System')
       ->to('primary.user@example.com', 'Primary User')
       ->cc('team.lead@example.com')
       ->bcc(['logs@example.com', 'security@example.com'])
       ->subject('Deployment Complete')
       ->message('The deployment finished successfully at '.now())
       ->attach(storage_path('app/logs.zip'))
       ->send();
```

## Behaviour and notes

- The Mailer uses PHPMailer under the hood and configures it from `config('mailer.*')`.
- When rendering a Blade view the Mailer sets the message as HTML. If the view is missing it falls back to a plaintext message.
- Attachments added through a `Mailable` must be instances of `Illuminate\Mail\Mailables\Attachment` (the Mailer checks for this type).

## Contributing

Contributions are welcome. Please open issues or PRs against the upstream repository: https://github.com/wisedev99/mega-mailer

## License

This project is licensed under the MIT License.

```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance63

Regular maintenance activity

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~162 days

Total

3

Last Release

225d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2342eb650a65761b5d892435517edaf45bd0dd3c35136de85426e0e61a98688c?d=identicon)[wisedev99](/maintainers/wisedev99)

---

Top Contributors

[![wisedev99](https://avatars.githubusercontent.com/u/86822394?v=4)](https://github.com/wisedev99 "wisedev99 (29 commits)")

### Embed Badge

![Health badge](/badges/mega-tj-mailer/health.svg)

```
[![Health](https://phpackages.com/badges/mega-tj-mailer/health.svg)](https://phpackages.com/packages/mega-tj-mailer)
```

###  Alternatives

[ivantcholakov/codeigniter-phpmailer

A CodeIgniter 3 compatible email-library powered by PHPMailer.

25313.9k](/packages/ivantcholakov-codeigniter-phpmailer)[markguinn/silverstripe-email-helpers

Silverstripe extension containing SMTP mailer class and some other classes for HTML emails

3145.4k1](/packages/markguinn-silverstripe-email-helpers)[msp/smtp

SMTP with PHPMailer

2129.4k](/packages/msp-smtp)[nfephp-org/sped-mail

API para geração e envio dos emails relacionados com o SPED.

1123.7k](/packages/nfephp-org-sped-mail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
