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

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

tinymeng/mailer
===============

php发送邮件email

v2.1.3(1y ago)33011MITPHPPHP &gt;=7.0CI failing

Since Sep 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/majiameng/phpMailer)[ Packagist](https://packagist.org/packages/tinymeng/mailer)[ RSS](/packages/tinymeng-mailer/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (2)Versions (10)Used By (0)

tinymeng/mailer
===============

[](#tinymengmailer)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0d3e44c34492d573ca7b806fb5c2dfd1e0c66b279721bcb87094382dba5f938f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d616a69616d656e672f7068704d61696c65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/majiameng/phpMailer/?branch=master)[![Build Status](https://camo.githubusercontent.com/620188659a898f05e679f704eed616c590f8e0dd9cc1f7a825ccacc43e725fe0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d616a69616d656e672f7068704d61696c65722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/majiameng/phpMailer/build-status/master)[![Latest Stable Version](https://camo.githubusercontent.com/49dcf6afdfbad7bc88cf8fc812130519f8b9f624078d80452ffbf5bcbcad9491/68747470733a2f2f706f7365722e707567782e6f72672f74696e796d656e672f6d61696c65722f762f737461626c65)](https://packagist.org/packages/tinymeng/mailer)[![Total Downloads](https://camo.githubusercontent.com/5e1426fbcba66652917a42e213e7575001034de2369af2f0722bb47f0cd88814/68747470733a2f2f706f7365722e707567782e6f72672f74696e796d656e672f6d61696c65722f646f776e6c6f616473)](https://github.com/majiameng/phpMailer/tags)[![Latest Unstable Version](https://camo.githubusercontent.com/5dbfd30c97299aea7127c6b1749bc51cf2aa06a8d1d8acda1b907c4df3789f2e/68747470733a2f2f706f7365722e707567782e6f72672f74696e796d656e672f6d61696c65722f762f756e737461626c65)](https://packagist.org/packages/tinymeng/mailer)[![License](https://camo.githubusercontent.com/8da7edc646db76d14c27be05c33ed52a6b1339f25ac151ff4a9bca012b488fa1/68747470733a2f2f706f7365722e707567782e6f72672f74696e796d656e672f6d61696c65722f6c6963656e7365)](https://github.com/majiameng/phpMailer/blob/master/LICENSE)

PHP发送邮件要么使用起来太难理解，要么文件结构太杂乱，只有自己撸起袖子干了。最少逻辑使用最简单的Email发送!!!

- 给多人发送Email
- cc抄送人（用于将电子邮件的副本发送给其他收件人）
- bcc隐性抄送人(用于将电子邮件的隐秘副本发送给其他收件人)
- 添加附件
- 发送Html带样式的邮件

### Install

[](#install)

```
composer require tinymeng/mailer ^2.0 -vvv

```

### 使用

[](#使用)

> 类库使用的命名空间为`\\tinymeng\\mailer`

```
use tinymeng\mailer\Email;

//******************** 配置信息 start ********************************
$config = [
   'host'  => 'smtp.qq.com',
   'port'    => '465',
   'encryption'=> 'ssl',
   'username'=> '********@qq.com',
   'password'=> '********',
   'from_address'=> '*******@qq.com',
   'from_name'=> 'TinyMeng管理员',
];
//******************** 配置信息 end ********************************

$email = Email::smtp($config);
$email->setDebug(true);//线上注释此行
$email->toEmail("879042886@qq.com");
// $email->toEmail("879042886@qq.com,879042775@qq.com");//多账号已逗号隔开
$mailtitle = "饭后等你,测试邮件发送";
$mailcontent = "饭后等你,测试邮件发送";
$mailtype = "html";
//$cc = "xxx2886@qq.com";
//$bcc = "xxx1234@qq.com";
//$attachments = ["F:\git\admin_management_api\app\command\Hello.php"];
//$email->addAttachments($attachments);//添加附件
//$email->ccEmail($cc);//抄送人
//$email->bccEmail($bcc);//隐性抄送人
$state = $email->sendmail( $mailtitle, $mailcontent, $mailtype);
if($state==""){
   exit("发送失败");
}
exit("发送成功");
```

> 在config中可配置的参数

```
$host;        //发送email Host
$port;        //端口 25 or 456
$encryption;  //加密 ssl
$username;    //邮箱用户名(发送人email)
$password;    //邮箱密码(如果是第三方请去设置里获取)
$from_address;//发送人email
$from_name;   //发送人名称
$to_address;   //接收人email
$log_file = false;//记录日志
$host_name = "localhost"; //is used in HELO command
$time_out = 30;//is used in fsockopen()
```

> 如报错

```
/**
 *  'Trying to smtp.163.com:25 Error: Cannot connenct to relay host smtp.163.com
 * Error: Connection timed out (110) Error: Cannot send email to 879042886@qq.com'
 *
 * port: 一般我们配置的smtp服务器端口都是25，不过有的服务器或空间提供商把25端口给禁用了，比如阿里云就给禁用了，
 * 这个可以找相应的提供商确认一下。如果真是禁用了25端口，可以采用465端口，
 * 这个端口很多主流的邮件服务商像网易邮箱、QQ邮箱、阿里云邮箱也都支持，采用了465端口，
 * 注意，部分smtp服务器地址前面一定要加上ssl://，否则还是不可用。
 */

```

### 实例使用

[](#实例使用)

composer require tinymeng/mailer dev-master -vvv

将`example`文件下的 `index.html`和`sendmail.php`文件放在与vendor平级目录

修改`sendmail.php`对应的配置

> 注: 邮箱不能自己给自己发送

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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

Recently: every ~26 days

Total

9

Last Release

559d ago

Major Versions

v1.0.0 → v2.0.02019-09-26

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.0

v2.1.2PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f00d0a29ab429fef8e40769a695213a7adcaff7cb9ba6dc1eb77e0d9655e0618?d=identicon)[tinymeng](/maintainers/tinymeng)

---

Top Contributors

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

---

Tags

emailmailerphpemailsendemailtinymengemailmailertinymeng

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[aplus/email

Aplus Framework Email Library

2561.6M3](/packages/aplus-email)[sylius/mailer-bundle

Mailers and e-mail template management for Symfony projects.

728.7M89](/packages/sylius-mailer-bundle)[voku/bounce-mail-handler

Bounce Mail Handler

50246.0k2](/packages/voku-bounce-mail-handler)[nickcv/yii2-mandrill

Mandrill Api Integration for Yii2

29576.8k2](/packages/nickcv-yii2-mandrill)[boundstate/yii2-mailgun

Mailgun integration for the Yii framework

28165.8k](/packages/boundstate-yii2-mailgun)[hafael/azure-mailer-driver

Supercharge your Laravel or Symfony app with Microsoft Azure Communication Services (ACS)! Effortlessly add email, chat, voice, video, and telephony-over-IP for next-level communication. 🚀

15130.8k](/packages/hafael-azure-mailer-driver)

PHPackages © 2026

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