PHPackages                             inventor96/mako-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. inventor96/mako-mailer

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

inventor96/mako-mailer
======================

A simple emailing package for the PHP Mako framework.

v1.1.0(2w ago)0511MITPHPPHP &gt;=8.1

Since Oct 22Pushed 2w agoCompare

[ Source](https://github.com/inventor96/mako-mailer)[ Packagist](https://packagist.org/packages/inventor96/mako-mailer)[ RSS](/packages/inventor96-mako-mailer/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (7)Dependencies (6)Versions (8)Used By (1)

Mako Mailer
===========

[](#mako-mailer)

A simple emailing package for the PHP Mako framework. It provides an abstraction layer over email sending libraries, allowing for easy swapping of underlying implementations. The default adapter uses PHPMailer (included in this package).

Installation
------------

[](#installation)

1. Install the composer package:

    ```
    composer require inventor96/mako-mailer
    ```
2. Enable the package in Mako:
    `app/config/application.php`:

    ```
    [
        'packages' => [
            'web' => [
                \inventor96\MakoMailer\MailerPackage::class
            ],
        ],
    ];
    ```

    This will automatically register the `Mailer` class in the Mako dependency injection container, including the alias `mailer`.

Configuration
-------------

[](#configuration)

Create a new file at `app/config/packages/mailer/email.php`, and add any of the following applicable configuration options:

```
return [
    /**
     * The name of the sender.
     */
    'from_name' => 'MakoMailer',

    /**
     * The email address of the sender.
     */
    'from_email' => 'noreply@example.com',

    /**
     * The name of the default reply-to address.
     */
    'reply_to_name' => 'MakoMailer',

    /**
     * The email address of the default reply-to address.
     * Set to an empty string to disable the default reply-to.
     */
    'reply_to_email' => '',

    /**
     * The email adapter class to use.
     * Must implement `inventor96\MakoMailer\interfaces\EmailSenderInterface`.
     */
    'adapter' => inventor96\MakoMailer\adapters\PHPMailerAdapter::class,

    /**
     * ========= PHPMailer Settings =========
     */

    /**
     * Whether to use SMTP for sending emails.
     * Set to `false` to use the mail() function.
     */
    'use_smtp' => true,

    /**
     * SMTP server host.
     */
    'host' => 'smtp.example.com',

    /**
     * SMTP server port.
     */
    'port' => 465,

    /**
     * Encryption method to use.
     * Set to empty string to disable encryption.
     */
    'encryption' => PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_SMTPS,

    /**
     * Whether to use SMTP authentication.
     */
    'auth' => true,

    /**
     * SMTP username.
     */
    'username' => 'noreply@example.com',

    /**
     * SMTP password.
     */
    'password' => 'MySecurePassword123!',
];
```

Usage
-----

[](#usage)

### Basics

[](#basics)

You can use the `inventor96\MakoMailer\Mailer` or the `mailer` alias in the Mako dependency injection container. Here's a basic example in the context of a controller method:

```
use inventor96\MakoMailer\Mailer;
use inventor96\MakoMailer\EmailUser;

function sendWelcomeEmail(Mailer $mailer) {
    $to = new EmailUser('recipient@example.com', 'Recipient Name');
    $from = new EmailUser('noreply@example.com', 'MakoMailer');

    $sent = $mailer->send( // alternatively use `$this->mailer->send();` if using the alias
        [$to],
        'Welcome to Mako Mailer!',
        'Hello and welcome to Mako Mailer!',
        $from, // optional, will use config defaults if not provided
    );

    if ($sent) {
        echo "Email sent successfully!";
    } else {
        echo "Failed to send email.";
    }
}
```

### Email Templates

[](#email-templates)

You can also use Mako's view templates for email content. Here's an example:

```
use inventor96\MakoMailer\Mailer;
use inventor96\MakoMailer\EmailUser;

function sendWelcomeEmail(Mailer $mailer) {
    $to = new EmailUser('recipient@example.com', 'Recipient Name');
    $from = new EmailUser('noreply@example.com', 'MakoMailer');

    $sent = $mailer->sendTemplate(
        [$to],
        'Welcome to Mako Mailer!',
        'emails/welcome', // path to the view template, relative to the views directory. e.g. 'emails/welcome' for 'app/resources/views/emails/welcome.tpl.php'
        [
            'name' => 'Recipient Name',
        ],
        $from, // optional, will use config defaults if not provided
    );

    if ($sent) {
        echo "Email sent successfully!";
    } else {
        echo "Failed to send email.";
    }
}
```

### EmailUser

[](#emailuser)

The `EmailUser` class is a simple value object that represents an email user (i.e., the sender or recipient of an email). It contains the user's email address and name. You can either create an instance of `EmailUser` directly (as shown above) or use the static `fromUser()` method to create an instance from an object that implements `inventor96\MakoMailer\interfaces\EmailUserInterface`:

```
use inventor96\MakoMailer\EmailUser;
use inventor96\MakoMailer\interfaces\EmailUserInterface;
use mako\gatekeeper\entities\user\User as GatekeeperUser;

class User extends GatekeeperUser implements EmailUserInterface {
    public function getEmail(): string {
        return $this->email;
    }

    public function getName(): string {
        return $this->first_name . ' ' . $this->last_name;
    }
}

$user = User::getOrThrow(1); // fetch user from database
$to = EmailUser::fromUser($user);

$mailer->send([$to], 'Subject', 'Email body');
```

### Reply-To

[](#reply-to)

You can set a default reply-to address in the [email config](#configuration) (`reply_to_email` and `reply_to_name`). You can also override it per-email by passing an `EmailUser` as the reply-to:

```
use inventor96\MakoMailer\EmailUser;

$replyTo = new EmailUser('support@example.com', 'Support Team');

$mailer->send(
    [$to],
    'Subject',
    'Email body',
    null,   // from (uses config default)
    $replyTo,
);
```

### Attachments

[](#attachments)

You can attach files to your emails using the `inventor96\MakoMailer\Attachment` class. Attachments are passed as the last argument to `send()` or `sendTemplate()`:

```
use inventor96\MakoMailer\Attachment;

$attachment = Attachment::fromPath('/path/to/invoice.pdf');
$logo = Attachment::fromData($binaryLogoData, 'logo.png', Attachment::ENCODING_BASE64, 'image/png', Attachment::DISPOSITION_INLINE);

$mailer->send(
    [$to],
    'Subject',
    'Email body',
    null,       // from (uses config default)
    null,       // reply-to (uses config default)
    [$attachment, $logo],
);
```

The `Attachment` class supports both file attachments (`Attachment::fromPath()`) and string data attachments (`Attachment::fromData()`). It also accepts optional encoding, mime type, and disposition arguments. The `Attachment::DISPOSITION_INLINE` disposition can be used for embedded images.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance97

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

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 ~47 days

Recently: every ~70 days

Total

7

Last Release

15d ago

PHP version history (3 changes)v1.0.0PHP ~8.1.0|~8.2.0|~8.3.0

v1.0.4PHP ~8.1.0 || ~8.2.0 || ~8.3.0

v1.0.5PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7132744?v=4)[Caleb Hornbeck](/maintainers/inventor96)[@inventor96](https://github.com/inventor96)

---

Top Contributors

[![inventor96](https://avatars.githubusercontent.com/u/7132744?v=4)](https://github.com/inventor96 "inventor96 (12 commits)")

---

Tags

emailmakomailer

### Embed Badge

![Health badge](/badges/inventor96-mako-mailer/health.svg)

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k39.6k](/packages/matomo-matomo)[sylius/mailer-bundle

Mailers and e-mail template management for Symfony projects.

728.8M91](/packages/sylius-mailer-bundle)[nickcv/yii2-mandrill

Mandrill Api Integration for Yii2

29585.1k2](/packages/nickcv-yii2-mandrill)

PHPackages © 2026

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