定制 phalcon/incubator-mailer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phalcon/incubator-mailer

最新稳定版本:v3.0.0

Composer 安装命令:

composer require phalcon/incubator-mailer

包简介

Phalcon Incubator Mailer Adapters

README 文档

README

Discord Packagist Version PHP from Packagist codecov Packagist

Usage examples of the mailer wrapper over PHPMailer for Phalcon:

Configure

SMTP

$config = [ 'driver' => 'smtp', 'host' => 'smtp.gmail.com', 'port' => 465, 'encryption' => 'ssl', 'username' => 'example@gmail.com', 'password' => 'your_password', 'from' => [ 'email' => 'example@gmail.com', 'name' => 'YOUR FROM NAME' ] ];

Sendmail

$config = [ 'driver' => 'sendmail', 'sendmail' => '/usr/sbin/sendmail -bs', 'from' => [ 'email' => 'example@gmail.com', 'name' => 'YOUR FROM NAME' ] ];

Send message

createMessage()

$mailer = new \Phalcon\Incubator\Mailer\Manager($config); $message = $mailer->createMessage() ->to('example_to@gmail.com', 'OPTIONAL NAME') ->subject('Hello world!') ->content('Hello world!'); // Set the Cc addresses of this message. $message->cc('example_cc@gmail.com'); // Set the Bcc addresses of this message. $message->bcc('example_bcc@gmail.com'); // Send message $message->send();

createMessageFromView()

// To create message with View, you need to define in the DI the component simple View.  $this->di->set( 'simple', function () use ($config) { $view = new Phalcon\Mvc\View\Simple(); $view->setViewsDir($config->application->viewsDir); return $view; }, true ); $this->di->setShared('view', function () use ($config) { $view = new Phalcon\Mvc\View($this->di); $view->setViewsDir($config->application->viewsDir); $view->registerEngines([ '.volt' => function ($view) { $volt = new Phalcon\Mvc\View\Engine\Volt($view, $this->di); $volt->setOptions([ 'path' => $config->application->cacheDir, 'separator' => '_' ]); return $volt; }, '.phtml' => Phalcon\Mvc\View\Engine\Php::class ]); return $view; }); $mailer = new \Phalcon\Incubator\Mailer\Manager($config); // view relative to the folder viewsDir (REQUIRED) $viewPath = 'email/example_message'; // Set variables to views (OPTIONAL) $params = [ 'var1' => 'VAR VALUE 1', 'var2' => 'VAR VALUE 2', // ... 'varN' => 'VAR VALUE N' ]; $message = $mailer->createMessageFromView($viewPath, $params) ->to('example_to@gmail.com', 'OPTIONAL NAME') ->subject('Hello world!'); // Set the Cc addresses of this message. $message->cc('example_cc@gmail.com'); // Set the Bcc addresses of this message. $message->bcc('example_bcc@gmail.com'); // Send message $message->send();

Events

https://docs.phalcon.io/5.0/en/events

All events are callables with at least 2 arguments

Look for each event down below for more informations of the third argument

- mailer:beforeCreateMessage function (Phalcon\Events\Event $event, Phalcon\Incubator\Mailer\Manager $manager, null) {}; - mailer:afterCreateMessage function (Phalcon\Events\Event $event, Phalcon\Incubator\Mailer\Manager $manager, Phalcon\Incubator\Mailer\Message $message) {}; - mailer:beforeSend function (Phalcon\Events\Event $event, Phalcon\Incubator\Mailer\Message $message, null) {}; - mailer:afterSend 2 arguments, the number of sent mails and an array of emails representing the failed recipients function (Phalcon\Events\Event $event, Phalcon\Incubator\Mailer\Message $message, [int $count, array $failedRecipients]) {}; - mailer:beforeAttachFile function (Phalcon\Events\Event $event, Phalcon\Incubator\Mailer\Message $message, null) {}; - mailer:afterAttachFile 1 argument, an array with the attachment informations function (Phalcon\Events\Event $event, Phalcon\Incubator\Mailer\Message $message, array $attachment) {}; 0: string (path of the file or encoded data) 1: string (name of the attachment) 2: string (basename of the attachment) 3: string (encoding) 4: string (MIME type) 5: bool (false -> encoded data, true -> from a file) 6: string (disposition of the mail) 7: string|0 (if from a file, name of the file)

统计信息

  • 总下载量: 16.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 3
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 6
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固