PHPackages                             phalapi/phpmailer - 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. phalapi/phpmailer

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

phalapi/phpmailer
=================

PhalApi 2.x扩展类库，基于PHPMailer的邮件发送。

92.0k4PHP

Since Oct 14Pushed 6y ago1 watchersCompare

[ Source](https://github.com/phalapi/PHPMailer)[ Packagist](https://packagist.org/packages/phalapi/phpmailer)[ RSS](/packages/phalapi-phpmailer/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHPMailer
=========

[](#phpmailer)

PhalApi 2.x扩展类库，基于PHPMailer的邮件发送。

安装和配置
-----

[](#安装和配置)

修改项目下的composer.json文件，并添加：

```
    "phalapi/phpmailer":"dev-master"

```

然后执行`composer update`，如果PHP版本过低，可使用`composer update --ignore-platform-reqs`。

安装成功后，添加以下配置到./config/app.php文件：

```
    'PHPMailer' => array(
        'email' => array(
            'host' => 'smtp.gmail.com',
            'port' => 465,
            'Secure' => 'ssl',
            'username' => 'XXX@gmail.com',
            'password' => '******',
            'from' => 'XXX@gmail.com',
            'fromName' => 'PhalApi团队',
            'sign' => '请不要回复此邮件，谢谢！-- PhalApi团队敬上 ',
        ),
    ),
```

注册
--

[](#注册)

在./config/di.php文件中，注册邮件服务：

```
$di->mailer = function() {
    return new \PhalApi\PHPMailer\Lite(true);
};
```

上面将依赖composer版本的PHPMailer；如果你的PHP版本 &lt;= PHP 5.3，则需要切换到第一版本：

```
$di->mailer = function() {
    return new \PhalApi\PHPMailer\LiteOne(true);
};
```

使用
--

[](#使用)

如下代码示例：

```
\PhalApi\DI()->mailer->send('chanzonghuang@gmail.com', 'Test PHPMailer Lite', 'something here ...');
```

稍候将会收到：

[![123123](https://camo.githubusercontent.com/f76473c25a955a4d5fc2a6b025949b0cc83dedce6512e886cf4ead0f635ebc71/687474703a2f2f776562746f6f6c732e71696e6975646e2e636f6d2f32303135303431313030353235375f3665366337613631303335376366383065343531333535376131313064383664)](https://camo.githubusercontent.com/f76473c25a955a4d5fc2a6b025949b0cc83dedce6512e886cf4ead0f635ebc71/687474703a2f2f776562746f6f6c732e71696e6975646e2e636f6d2f32303135303431313030353235375f3665366337613631303335376366383065343531333535376131313064383664)

如果需要发送邮件给多个邮箱时，可以使用数组，如：

```
$addresses = array('chanzonghuang@gmail.com', 'test@phalapi.com');
\PhalApi\DI()->mailer->send($addresses, 'Test PHPMailer Lite', 'something here ...');
```

调试日志
----

[](#调试日志)

在注册初始化时，传入true可开启调试日志，并可以看到类如：

```
2017-09-03 10:10:58|DEBUG|Succeed to send email|{"addresses":["chanzonghuang@gmail.com"],"title":"Test PHPMailer Lite"}

```

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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/35d70b1236f8f67d96ba3da4ba88889faf2837ff8f7ab62acc54fe6cb4992c87?d=identicon)[dogstarhuang](/maintainers/dogstarhuang)

---

Top Contributors

[![dogstarTest](https://avatars.githubusercontent.com/u/6116306?v=4)](https://github.com/dogstarTest "dogstarTest (7 commits)")[![phalapi](https://avatars.githubusercontent.com/u/12585518?v=4)](https://github.com/phalapi "phalapi (5 commits)")[![kai-oss-code](https://avatars.githubusercontent.com/u/32416615?v=4)](https://github.com/kai-oss-code "kai-oss-code (2 commits)")[![Harry-Studio](https://avatars.githubusercontent.com/u/51809618?v=4)](https://github.com/Harry-Studio "Harry-Studio (1 commits)")

### Embed Badge

![Health badge](/badges/phalapi-phpmailer/health.svg)

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

###  Alternatives

[mattketmo/email-checker

Throwaway email detection library

2752.1M5](/packages/mattketmo-email-checker)[sarfraznawaz2005/noty

Laravel package to incorporate noty flash notifications into laravel.

324.5k](/packages/sarfraznawaz2005-noty)

PHPackages © 2026

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