PHPackages                             vielhuber/mailhelper - 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. vielhuber/mailhelper

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

vielhuber/mailhelper
====================

Lightweight email integration layer.

1.8.1(2w ago)1243↑63.3%1MITPHPPHP &gt;=8.1

Since Nov 20Pushed 3w agoCompare

[ Source](https://github.com/vielhuber/mailhelper)[ Packagist](https://packagist.org/packages/vielhuber/mailhelper)[ RSS](/packages/vielhuber-mailhelper/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (34)Versions (83)Used By (1)

[![build status](https://github.com/vielhuber/mailhelper/actions/workflows/ci.yml/badge.svg)](https://github.com/vielhuber/mailhelper/actions)[![GitHub Tag](https://camo.githubusercontent.com/144f23da7cc43ed4db26efac69692c6f643050c5fc4e42eacc5f4b2a48df0490/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f7669656c68756265722f6d61696c68656c706572)](https://github.com/vielhuber/mailhelper/tags)[![Code Style](https://camo.githubusercontent.com/1540f8ce219727155ab62506c77b818b720421c22c4cf0b18a5f160942132e2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64655f7374796c652d7073722d2d31322d6666363962342e737667)](https://www.php-fig.org/psr/psr-12/)[![License](https://camo.githubusercontent.com/704ecbd61043af53766d4a06b14c4ba226665fda122787b5a646223d7150be8b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7669656c68756265722f6d61696c68656c706572)](https://github.com/vielhuber/mailhelper/blob/main/LICENSE.md)[![Last Commit](https://camo.githubusercontent.com/63f36417ae4ab8545d5284648d0882768995dc262ec2dfe5cb53b4ef3edf492d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f7669656c68756265722f6d61696c68656c706572)](https://github.com/vielhuber/mailhelper/commits)[![PHP Version Support](https://camo.githubusercontent.com/71586b3ae33aae35298cc402214ed11e5e257e5299dc4f3b7b1f2e27cfbd74dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7669656c68756265722f6d61696c68656c706572)](https://packagist.org/packages/vielhuber/mailhelper)[![Packagist Downloads](https://camo.githubusercontent.com/046930451f7de782723dc46b175abfc3d1e16584ecb9ef929f1c6495f62b70b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7669656c68756265722f6d61696c68656c706572)](https://packagist.org/packages/vielhuber/mailhelper)

📫 mailhelper 📫
==============

[](#-mailhelper-)

mailhelper is a lightweight email integration layer on top of [phpmailer](https://github.com/PHPMailer/PHPMailer) and [php-imap](https://github.com/Webklex/php-imap) that provides a simple cli, php wrapper, and mcp server for fetching messages, sending emails, and wiring email functionality into existing tooling without having to deal with complex imap/smtp configuration yourself.

requirements
------------

[](#requirements)

- php &gt;= 8.1

installation
------------

[](#installation)

### composer

[](#composer)

```
composer require vielhuber/mailhelper
```

### create config

[](#create-config)

```
vi config.json
```

```
{
    "info@example.com": {
        "imap": {
            "host": "imap.example.com",
            "port": 993,
            "username": "info@example.com",
            "password": "***",
            "encryption": "ssl",
            "fix_order": false
        },
        "smtp": {
            "host": "smtp.example.com",
            "port": 465,
            "username": "info@example.com",
            "password": "***",
            "encryption": "ssl"
        },
        "test": true
    },
    "support@company.com": {
        "imap": {
            "host": "outlook.office365.com",
            "port": 993,
            "tenant_id": "***",
            "client_id": "***",
            "client_secret": "***",
            "encryption": "tls",
            "fix_order": false
        },
        "smtp": {
            "host": "smtp.office365.com",
            "port": 587,
            "tenant_id": "***",
            "client_id": "***",
            "client_secret": "***",
            "encryption": "tls"
        },
        "test": false
    }
}
```

### exchange support

[](#exchange-support)

- see

### test

[](#test)

`./vendor/bin/phpunit`

usage
-----

[](#usage)

### cli

[](#cli)

```
./vendor/bin/mailhelper.php fetch-mails \
    --mailbox "xxx@tld.com" \
    --folder "INBOX/foo/bar" \
    --filter-date-from "YYYY-MM-DD HH:II:SS" \
    --filter-date-until "YYYY-MM-DD HH:II:SS" \
    --filter-subject "pattern" \
    --filter-content "pattern" \
    --filter-to "pattern" \
    --filter-cc "pattern" \
    --limit 42 \
    --order "desc" \
    --progress

./vendor/bin/mailhelper.php send-mail \
    --mailbox "xxx@tld.com" \
    --subject "This is a test! 🚀" \
    --content "✅ Test successful!" \
    --content-plain "Test successful!" \
    --from-name "John Doe" \
    --to "aaa@tld.com" \
    --to '["aaa@tld.com", "bbb@tld.com"]' \
    --to '[{"name": "John Doe", "email": "aaa@tld.com"}, {"name": "Jane Doe", "email": "bbb@tld.com"}]' \
    --cc "aaa@tld.com" \
    --bcc "aaa@tld.com" \
    --attachments "/test1.jpg" \
    --attachments '["/test1.jpg", "/test2.jpg"]' \
    --attachments '[{"name": "foo1.jpg", "file": "/test1.jpg"}, {"name": "foo2.jpg", "file": "/test2.jpg"}]'

./vendor/bin/mailhelper.php save-draft \
    --mailbox "xxx@tld.com" \
    # ... (see send-mail)

./vendor/bin/mailhelper.php send-draft \
    --mailbox "xxx@tld.com" \
    --id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

./vendor/bin/mailhelper.php view-mail \
    --mailbox "xxx@tld.com" \
    --folder "INBOX/foo/bar" \
    --id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
    --inline-files

./vendor/bin/mailhelper.php move-mail \
    --mailbox "xxx@tld.com" \
    --folder "INBOX/foo/bar" \
    --id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
    --name "INBOX/foo/bar"

./vendor/bin/mailhelper.php delete-mail \
    --mailbox "xxx@tld.com" \
    --folder "INBOX/foo/bar" \
    --id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

./vendor/bin/mailhelper.php read-mail \
    --mailbox "xxx@tld.com" \
    --folder "INBOX/foo/bar" \
    --id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

./vendor/bin/mailhelper.php unread-mail \
    --mailbox "xxx@tld.com" \
    --folder "INBOX/foo/bar" \
    --id "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

./vendor/bin/mailhelper.php get-folders \
    --mailbox "xxx@tld.com"

./vendor/bin/mailhelper.php quota \
    --mailbox "xxx@tld.com"

./vendor/bin/mailhelper.php create-folder \
    --mailbox "xxx@tld.com"
    --name "INBOX/foo"

./vendor/bin/mailhelper.php rename-folder \
    --mailbox "xxx@tld.com"
    --name-old "INBOX/foo"
    --name-new "INBOX/bar"

./vendor/bin/mailhelper.php delete-folder \
    --mailbox "xxx@tld.com"
    --name "INBOX/foo"

./vendor/bin/mailhelper.php get-config
```

### php

[](#php)

```
require_once __DIR__ . '/vendor/autoload.php';
use vielhuber\mailhelper\mailhelper;

$mailhelper = new mailhelper();

$mailhelper->fetchMails(
    mailbox: 'xxx@tld.com',
    folder: 'INBOX/foo/bar',
    filter: [
        'date_from' => date('Y-m-d H:i:s', strtotime('now - 1 hour')),
        'date_until' => date('Y-m-d H:i:s', strtotime('now')),
        'subject' => 'pattern',
        'content' => 'pattern',
        'from' => 'pattern',
        'to' => 'pattern',
        'cc' => 'pattern'
    ],
    limit: 42,
    order: 'asc',
    progress: false
);

$mailhelper->sendMail(
    mailbox: 'xxx@tld.com',
    subject: 'This is a test! 🚀',
    content: '✅ Test successful!',
    content_plain: 'Test successful!',
    to: 'aaa@tld.com',
    to: ['aaa@tld.com', 'bbb@tld.com'],
    to: [['name' => 'John Doe', 'email' => 'aaa@tld.com'], ['name' => 'Jane Doe', 'email' => 'bbb@tld.com']],
    cc: 'aaa@tld.com',
    bcc: 'aaa@tld.com',
    from_name: 'John Doe',
    attachments: __DIR__ . '/test1.jpg',
    attachments: [__DIR__ . '/test1.jpg', __DIR__ . '/test2.jpg'],
    attachments: [
        ['name' => 'foo1.jpg', 'file' => __DIR__ . '/test1.jpg'],
        ['name' => 'foo2.jpg', 'file' => __DIR__ . '/test2.jpg']
    ]
);

$mailhelper->saveDraft(
    mailbox: 'xxx@tld.com',
    // ... (see sendMail)
);

$mailhelper->sendDraft(
    mailbox: 'xxx@tld.com',
    id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
);

$mailhelper->viewMail(
    mailbox: 'xxx@tld.com',
    folder: 'INBOX/foo/bar',
    id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    inline_files: false
);

$mailhelper->moveMail(
    mailbox: 'xxx@tld.com',
    folder: 'INBOX/foo/bar',
    id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    name: 'INBOX/foo/bar'
);

$mailhelper->deleteMail(
    mailbox: 'xxx@tld.com',
    folder: 'INBOX/foo/bar',
    id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);

$mailhelper->readMail(
    mailbox: 'xxx@tld.com',
    folder: 'INBOX/foo/bar',
    id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);

$mailhelper->unreadMail(
    mailbox: 'xxx@tld.com',
    folder: 'INBOX/foo/bar',
    id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);

$mailhelper->getFolders(
    mailbox: 'xxx@tld.com'
);

$mailhelper->quota(
    mailbox: 'xxx@tld.com'
);

$mailhelper->createFolder(
    mailbox: 'xxx@tld.com'
    name: 'INBOX/foo'
);

$mailhelper->renameFolder(
    mailbox: 'xxx@tld.com'
    name_old: 'INBOX/foo',
    name_new: 'INBOX/bar'
);

$mailhelper->deleteFolder(
    mailbox: 'xxx@tld.com'
    name: 'INBOX/foo'
);

$mailhelper->getConfig();

$mailhelper = new mailhelper(config: [
    "info@example.com" => [
        "imap" => [
            "host" => "imap.example.com",
            /* ... */
        ],
        /* ... */
    },
    /* ... */
]);
```

### mcp

[](#mcp)

```
{
    "mcpServers": {
        "email": {
            "command": "/usr/bin/php8.1",
            "args": ["/var/www/project/vendor/bin/mcp-server.php"]
        }
    }
}
```

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance96

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

82

Last Release

16d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3183737?v=4)[David Vielhuber](/maintainers/vielhuber)[@vielhuber](https://github.com/vielhuber)

---

Top Contributors

[![vielhuber](https://avatars.githubusercontent.com/u/3183737?v=4)](https://github.com/vielhuber "vielhuber (82 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vielhuber-mailhelper/health.svg)

```
[![Health](https://phpackages.com/badges/vielhuber-mailhelper/health.svg)](https://phpackages.com/packages/vielhuber-mailhelper)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[saithink/saiadmin

webman plugin

28211.5k1](/packages/saithink-saiadmin)[doppar/framework

The Doppar Framework

4012.4k14](/packages/doppar-framework)

PHPackages © 2026

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