Download the PHP package liwenyu/yii2-swiftmailer without Composer

On this page you can find all versions of the php package liwenyu/yii2-swiftmailer. 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 yii2-swiftmailer

Yii2 Mailer Extension

基于 yii2-swiftmailer 的 Yii2 扩展,实现微软邮件发送功能。

功能特性

与官方 yii2-swiftmailer 的功能对比

完全支持的功能

1. 基础邮件发送功能

2. 消息属性支持

3. 附件功能

4. 邮件属性

🚀 额外增强功能

1. Microsoft Graph API 集成

2. 高级功能

📋 功能对比表

功能 官方 yii2-swiftmailer 本扩展 说明
基础发送 完全兼容
视图模板 完全兼容
HTML/文本 完全兼容
附件 完全兼容
嵌入图片 完全兼容
抄送/密送 完全兼容
回复地址 完全兼容
字符编码 完全兼容
优先级 完全兼容
重要性 完全兼容
敏感度 完全兼容
批量发送 扩展功能
简单发送 扩展功能
Microsoft Graph 扩展功能
邮件管理 扩展功能
OAuth2 认证 扩展功能

🔄 无缝迁移

您可以直接替换官方 yii2-swiftmailer,现有代码无需任何修改:

🔄 从官方 yii2-swiftmailer 迁移

1. 安装扩展

2. 更新配置

使用 Microsoft Graph API(推荐)

继续使用 SMTP 传输

配置差异说明

3. 代码无需修改

🔧 配置验证工具

为了方便验证 Microsoft Exchange 配置,我们提供了专门的验证工具:

📁 Microsoft_check 目录

Microsoft_check/ 目录包含了完整的配置验证工具:

🚀 快速验证

📋 验证项目

验证工具会检查以下 5 个方面:

  1. ✅ 基本配置 - 检查必需字段是否填写
  2. ✅ OAuth2 认证 - 验证客户端凭据是否正确
  3. ✅ API 连接 - 测试与 Microsoft Graph API 的连接
  4. ✅ 邮件权限 - 验证是否有邮件发送权限
  5. ✅ 邮件发送 - 发送测试邮件验证功能

🔒 安全特性

详细说明请查看 Microsoft_check/README.md 文件。

安装

通过 Composer 安装

手动安装

  1. 下载扩展文件到 vendor/liwenyu/yii2-swiftmailer 目录
  2. composer.json 中添加自动加载配置

配置

1. 在应用配置中注册组件

使用 Microsoft Graph API(推荐)

使用 SMTP 传输

2. Microsoft Azure 应用注册

在使用此扩展之前,您需要在 Microsoft Azure 门户中注册一个应用程序:

  1. 访问 Azure 门户
  2. 导航到 "Azure Active Directory" > "应用注册"
  3. 点击 "新注册"
  4. 填写应用信息:
    • 名称:您的应用名称
    • 支持的账户类型:选择适当的选项
    • 重定向 URI:可选
  5. 注册完成后,记录以下信息:
    • 应用程序(客户端)ID
    • 目录(租户)ID
  6. 在 "证书和密码" 部分创建客户端密码
  7. 在 "API 权限" 部分添加以下权限:
    • Mail.Send (发送邮件)
    • Mail.ReadWrite (读写邮件)
    • User.Read (读取用户信息)

使用方法

基本邮件发送

使用消息对象发送邮件

批量发送邮件

使用 Graph API 服务

使用视图模板发送邮件

对应的视图文件 views/mail/welcome-email.php

高级功能

邮件草稿

错误处理

配置选项

MicrosoftMailConfig 配置选项

选项 类型 必需 默认值 描述
clientId string - Azure 应用客户端 ID
clientSecret string - Azure 应用客户端密钥
tenantId string - Azure 租户 ID
userEmail string - 发送邮件的用户邮箱
graphApiUrl string https://graph.microsoft.com/v1.0 Graph API 基础 URL
authUrl string https://login.microsoftonline.com OAuth2 认证 URL

Mailer 配置选项

选项 类型 必需 默认值 描述
config MicrosoftMailConfig - Microsoft Graph API 配置对象(useSmtp=false 时必需)
transport array - SMTP 传输配置(useSmtp=true 时必需)
useSmtp bool false 是否使用 SMTP 传输
messageClass string liwenyu\swiftmailer\Message 消息类
debug bool false 是否启用调试模式

故障排除

常见问题

  1. 认证失败

    • 检查 clientIdclientSecrettenantId 是否正确
    • 确认 Azure 应用权限配置正确
    • 检查客户端密钥是否过期
  2. 邮件发送失败

    • 确认 userEmail 有发送邮件的权限
    • 检查收件人邮箱地址格式是否正确
    • 查看应用日志获取详细错误信息
  3. API 调用失败
    • 检查网络连接
    • 确认 Graph API 权限配置
    • 查看 Microsoft Graph API 状态页面

调试模式

启用调试模式可以查看详细的请求和响应信息:

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

更新日志

1.0.0

🎉 总结

本扩展 完全支持 官方 yii2-swiftmailer 的所有功能,并且提供了额外的 Microsoft Graph API 集成功能。您可以:

  1. 无缝替换 - 直接替换官方扩展,代码无需修改
  2. 功能增强 - 享受 Microsoft Graph API 的强大功能
  3. 向后兼容 - 保持与现有代码的完全兼容性
  4. 扩展能力 - 使用新增的批量发送和邮件管理功能

这使得本扩展成为官方 yii2-swiftmailer 的完美替代品,同时提供了更强大的 Microsoft 邮件服务集成能力。


All versions of yii2-swiftmailer with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
yiisoft/yii2 Version ~2.0.0
yiisoft/yii2-swiftmailer Version ~2.1.0
guzzlehttp/guzzle Version ^7.0
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 liwenyu/yii2-swiftmailer contains the following files

Loading the files please wait ...