Download the PHP package yzh52521/webman-mailer without Composer

On this page you can find all versions of the php package yzh52521/webman-mailer. 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 webman-mailer

webman-mailer

基于 symfony mailer二次开发 支持邮件模板、纯文本、附件邮件发送以及更多邮件功能, 邮件发送简单到只需一行代码

安装

配置

配置文件 config/plugin/yzh52521/mailer/app.php 内容如下

优雅的发送邮件

创建实例

不传递任何参数表示使用配置文件里默认的配置

设置发件人

发件人邮箱地址必须和配配置里的 username 一致

设置收件人

以下几种方式任选一种

设置抄送

以下几种方式任选一种

设置暗抄送

以下几种方式任选一种

设置回复邮件地址

设置邮件主题

设置邮件内容 - 纯文本

设置邮件内容 - HTML

设置邮件内容 - 模板

模板的使用, 具体请看webman视图怎么用, 第二个参数是要进行模板赋值的数组

https://www.workerman.net/doc/webman/view.html

以下介绍的是thinkphp模版使用

将图片作为元数据嵌入到邮件中

邮件内容中包含图片的, 可以直接指定 img 标签的 src 属性为远程图片地址, 此处图片地址必须为远程图片地址, 必须为一个带域名的完整图片链接, 这似乎很麻烦, 所以你还可以将图片作为元数据嵌入到邮件中, 至于其他文件是否也可以嵌入请自己尝试

下面介绍一下 webman-mailer 如何快速简便的将图片元数据嵌入到邮件中:

配置嵌入标签

嵌入元数据需要在模板赋值或者使用 setHtmlBody() 传递变量时, 给变量添加特殊的标签, 该嵌入标签默认为 cid:, 你可以修改配置文件中 embed 项, 修改为你想要的形式

模板或HTML中设置变量

在模板中, 例如 ThinkPHP框架 都是使用 {$var} 的形式传递变量, 假设变量为 image_src, 那么模板中填写 {$image_src}, 如果是在HTML中, 请使用 {image_src}, 注意如果修改过左、右定界符请使用自己定义的左右定界符

传递变量参数和值

setHtmlBody()view() 方法的第二个参数里, 该数组必须有一个变量, 格式为 ['cid:image_src'] => '/path/to/image.jpg'] 或者 ['cid:image_src'] => ['file_stream', 'filename','filemime']], 即参数数组的键名是上面配置的 嵌入标签 + 变量名, 但值有两种情况:

第一, 如果值为字符串, 则该值为图片的路径 (绝对路径或相对路径) 或者 有效的url地址 第二, 如果值为数组, 数组为 ['stream','name','mime'] 的形式, 其中 stream 表示图片的数据流, 即是未保存的文件数据流, 例如 fopen() 方法获取的文件数据流, 第二个参数为文件名, 默认为 image,第三个参数可选, 为文件的mime类型, 默认为 null

示例

其中模板的内容如下:

在 HTML 中使用一样:

添加附件

或者指定附件的文件名

设置消息加密/签名

设置字符编码

设置邮件优先级

发送邮件

使用匿名函数 $message是 \Symfony\Component\Mime\Email 对象

第二个参数是数组, 可以重新邮件配置

邮件发送失败会直接以异常抛出, 或者可以通过 getError() 获取错误信息

使用 getHeaders()getHeadersString() 方法可以获取头信息 getHeaders() 返回的是头信息数组, getHeadersString() 返回的是头信息字符串

Issues

如果有遇到问题请提交 issues

License

Apache 2.0


All versions of webman-mailer with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 || ^8.0
symfony/mailer Version ^5.4.5|^6.0
symfony/polyfill-php80 Version ^1.19
ext-fileinfo Version *
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 yzh52521/webman-mailer contains the following files

Loading the files please wait ....