PHPackages                             haerriz/module-smtprouting - 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. haerriz/module-smtprouting

ActiveMagento2-module[Mail &amp; Notifications](/categories/mail)

haerriz/module-smtprouting
==========================

Custom SMTP Routing module for Magento 2. Dynamically swaps SMTP credentials based on outgoing From address.

00PHP

Since Jul 13Pushed 1mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Haerriz SMTP Routing for Magento 2
==================================

[](#haerriz-smtp-routing-for-magento-2)

A lightweight Magento 2 module that dynamically intercepts outgoing emails and swaps the SMTP authentication credentials based on the `From` email address.

This is extremely useful for shared hosting environments (like Hostinger) that enforce strict anti-spoofing policies (e.g., `553 Sender address rejected: not owned by user`), requiring the SMTP login to match the exact outgoing email address.

Features
--------

[](#features)

- Bypasses strict anti-spoofing policies on shared hosting.
- Natively intercepts Magento's core `Magento\Email\Model\Transport` via a lightweight Plugin.
- Pulls credentials securely from Magento's `env.php` without hardcoding passwords in the database.
- Completely eliminates the need for bulky, paid SMTP extensions.

Installation via Composer
-------------------------

[](#installation-via-composer)

```
composer require haerriz/module-smtprouting
bin/magento module:enable Haerriz_SmtpRouting
bin/magento setup:upgrade
bin/magento setup:di:compile
```

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

[](#configuration)

1. In your server's `app/etc/env.php`, add an array mapping your sender emails to their SMTP passwords:

```
'smtp_mapping' => [
    'orders@yourstore.com' => 'orders_password',
    'newsletter@yourstore.com' => 'newsletter_password',
    'support@yourstore.com' => 'support_password'
],
```

2. Configure your primary Magento SMTP fallback credentials in `Stores > Configuration > Advanced > System > SMTP` as usual. If an email is sent that does not match a specific mapping in `env.php`, it will fall back to the primary credentials.

License
-------

[](#license)

MIT

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance60

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9fe1f320fec9ca3dd17c6141947c9bf4768c9e1d467d05c68207d4c9fccb218f?d=identicon)[haerriz](/maintainers/haerriz)

---

Top Contributors

[![haerriz](https://avatars.githubusercontent.com/u/29945587?v=4)](https://github.com/haerriz "haerriz (2 commits)")

---

Tags

anti-spoofingemail-routinghostingermagento-smtpmagento2magento2-modulesmtp

### Embed Badge

![Health badge](/badges/haerriz-module-smtprouting/health.svg)

```
[![Health](https://phpackages.com/badges/haerriz-module-smtprouting/health.svg)](https://phpackages.com/packages/haerriz-module-smtprouting)
```

###  Alternatives

[motomedialab/smtp2go

Send emails via API using the first-class email courier SMTP2Go

1327.0k](/packages/motomedialab-smtp2go)

PHPackages © 2026

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