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

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

windwork/mailer
===============

windwork mailer component，Windwork 发邮件组件

0.7.0(8y ago)07711MITPHPPHP &gt;=5.5.0

Since May 24Pushed 8y agoCompare

[ Source](https://github.com/windwork/wf-mailer)[ Packagist](https://packagist.org/packages/windwork/mailer)[ RSS](/packages/windwork-mailer/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)DependenciesVersions (6)Used By (1)

Windwork 发邮件组件
==============

[](#windwork-发邮件组件)

封装API通过SMTP/mail函数发送邮件。 如果服务器安装有邮件服务器，如sendmail等，则可以使用内置的mail函数发送邮件获得更高的性能和更多的个性化参数，否则使用smtp发送。 \*nix服务器上建议安装postfix邮件服务器，通过mail函数发送邮件。

安装
--

[](#安装)

该组件已包含在Windwork框架中，如果你已安装Windwork框架则可以直接使用。

- 安装方式一：通过composer安装（推荐）

```
composer require windwork/wf

```

- 安装方式二：传统方式安装
    [下载源码](https://github.com/windwork/wf/releases)后，解压源码到项目文件夹中，然后require\_once $PATH\_TO\_WF/core/lib/Loader.php文件，即可自动加载组件中的类。

使用方法
====

[](#使用方法)

```
1. 在 config/app.php中设置 srv.mailer 配置
2. 获取邮件实例来发送邮件，wfMailer()->send('收件人邮箱', '邮件标题', '邮件内容');

```

使用案例
----

[](#使用案例)

```
// 使用smtp发送
$cfg = [
    'class' => '\\wf\\mailer\\adapter\\SMTP', // SMTP）使用smtp发送邮件；Mail）使用mail函数发送邮件
    'port' => 25,
    'host' => 'smtp服务器',
    'auth' => true,
    'user' => 'smtp账号',
    'pass' => '邮箱密码',
];
$class = $cfg['class'];
$mailer = new $class($cfg);

// 在windwork应用中使用下面的方式创建实例，不需要前面的代码，配置信息在config/app.php中设置
//$mailer = wfMailer();
$mailer->send('收件人邮箱', '邮件标题', '邮件内容');

// 使用内置mail函数发送
$cfg = [
    'class'  => '\\wf\\mailer\\adapter\\Mail',
    'user'   => 'xxx@xxx.com', // 发件邮箱
];
$class = $cfg['class'];
$mailer = new $class($cfg);
$mailer->send('收件人邮箱', '邮件标题', '邮件内容');

```

发送邮件接口
------

[](#发送邮件接口)

```
namespace wf\mailer;

/**
 * 发送邮件接口
 *
 * @package     wf.mailer
 * @author      cm
 * @link        http://docs.windwork.org/manual/wf.mailer.html
 * @since       0.1.0
 */
interface MailerInterface
{
    /**
     * 发送邮件
     *
     * @param string $to 收件邮箱
     * @param string $subject  邮件主题
     * @param string $message  邮件内容
     * @param string $from = ''  发件邮箱，留空则使用配置中的邮箱账号
     * @param string $cc = '' 抄送，每个邮件用半角逗号隔开
     * @param string $bcc = ''  密送，每个邮件用半角逗号隔开
     * @return bool
     * @throws \wf\mailer\Exception
     */
    public function send($to, $subject, $message, $from = '', $cc = '', $bcc = '');
}

```

### 要了解更多？

[](#要了解更多)

> - [官方完整文档首页](http://docs.windwork.org/manual/)
> - [官方源码首页](https://github.com/windwork)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

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

Total

5

Last Release

3245d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/500cd48271ed61b12fbac17502e33a2b7ff364948c9ffe2d4a86d5d4d63540fb?d=identicon)[windwork](/maintainers/windwork)

---

Top Contributors

[![cmpan](https://avatars.githubusercontent.com/u/399927?v=4)](https://github.com/cmpan "cmpan (24 commits)")

---

Tags

mailmailerpostfixsendmailsmtpmailmailersmtpsendmailpostfix

### Embed Badge

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

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

###  Alternatives

[nette/mail

📧 Nette Mail: A handy library for creating and sending emails in PHP.

5389.8M246](/packages/nette-mail)[aplus/email

Aplus Framework Email Library

2461.6M3](/packages/aplus-email)[mlocati/spf-lib

Parse, build and validate SPF (Sender Policy Framework) DNS records

67867.9k2](/packages/mlocati-spf-lib)[pear/net_smtp

An implementation of the SMTP protocol

263.0M16](/packages/pear-net-smtp)[voku/bounce-mail-handler

Bounce Mail Handler

49230.9k2](/packages/voku-bounce-mail-handler)[boundstate/yii2-mailgun

Mailgun integration for the Yii framework

28160.6k](/packages/boundstate-yii2-mailgun)

PHPackages © 2026

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