Download the PHP package goletter/hyperf-mail without Composer

On this page you can find all versions of the php package goletter/hyperf-mail. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hyperf-mail

goletter/hyperf-mail

基于 Symfony Mailer 的 Hyperf 邮件组件,API 风格接近 Laravel Mailable。

支持 SMTP、Gmail、Mailgun、Postmark、AWS SES、Mandrill、阿里云 DM、Resend、sendmail、log 等驱动。

运行环境

安装

发布配置:

配置写入 config/autoload/mail.php。改完 .env 后需重启 Hyperf 进程。

API 类驱动(Mailgun、Postmark 等)通常还需:

快速开始


驱动配置

默认驱动由 MAIL_MAILER / mail.default 决定。多数云服务使用 DSN;SMTP 可用离散配置或 DSN。

SMTP(默认)

无需额外 Composer 依赖。

离散配置(推荐)

MAIL_SMTP_ENCRYPTION 含义 常用端口
tls STARTTLS(推荐) 587
ssl 隐式 SSL/TLS 465
留空 / null 不强制加密 25

对应 mail.mailers.smtp:

完整 DSN(可选)

设置 MAIL_SMTP_DSN 后忽略 host/port 等离散项:

用户名、密码中的 @、:、/ 等请先 URL 编码(@ → %40)。

Gmail

需开启两步验证,并使用应用专用密码。Symfony 建议仅用于开发/测试。

Mailgun

Postmark

AWS SES

Mandrill

阿里云 DM

仅支持事务类邮件,不支持批量。

Resend

sendmail / log

log 驱动不真正发信,只写入日志,适合本地开发。

全局发件人 / 统一收件人


编写 Mailable

类默认生成在 app/Mail。在 build() 中配置主题、正文、发件人与附件。

完整示例

发送:

发件人

未调用 from() 时使用 mail.from 全局配置。

正文内容

可用 视图模板 或 直接写字符串。HTML 与纯文本可只设其一,也可同时设置(推荐同时设置,兼容不支持 HTML 的客户端)。

直接写正文

视图模板

依赖 hyperf/view(本包已引入)。以 Blade 为例:

视图数据

指定 Mailer

未指定时使用 mail.default(即 MAIL_MAILER)。可用两种方式覆盖:

附件

文件系统附件依赖 hyperf/filesystem(本包已引入,需发布并配置)。

内联图片

模板中可直接使用 $message:

纯文本模板不要使用 $message 内联附件。

自定义 Symfony Email


发送邮件

to / cc / bcc 支持:邮箱字符串、字符串数组、Goletter\Contract\HasMailAddress 实例或其集合。

遍历多个收件人时,请为每人新建 Mailable(to() 会累加收件人):

队列

依赖 hyperf/async-queue,需先配置队列。

实现 HyperfExt\Contract\ShouldQueue 后,即使调用 send() 也会入队:

渲染 / 预览

路由或控制器中直接 return new InvoicePaid($invoice); 可在浏览器预览。

本地化

依赖 hyperf/translation。

模型实现 Goletter\Contract\HasLocalePreference 并返回 getPreferredLocale() 后,向该模型发信会自动使用其语言,无需再调 locale()。


本地开发

  1. log 驱动:MAIL_MAILER=log,邮件写入日志
  2. 统一收件人:配置 mail.to,所有外发改到同一地址
  3. Mailtrap 等:用真实 SMTP 发到测试邮箱

事件

事件 时机
Goletter\Mail\Events\MailMessageSending 真正发送前
Goletter\Mail\Events\MailMessageSent 发送完成后

队列入队时不会触发;仅在实际发送时触发。


常见问题


All versions of hyperf-mail with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-json Version *
ext-swoole Version >=4.5
hyperf-ext/contract Version ~2.2.0
hyperf/async-queue Version ^3.1
hyperf/command Version ^3.1
hyperf/config Version ^3.1
hyperf/devtool Version ^3.1
hyperf/di Version ^3.1
hyperf/event Version ^3.1
hyperf/filesystem Version ^3.1
hyperf/framework Version ^3.1
hyperf/translation Version ^3.1
hyperf/view Version ^3.1
pudongping/hyperf-wise-locksmith Version ^3.0
symfony/mailer Version ^6.0.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package goletter/hyperf-mail contains the following files

Loading the files please wait ...