trejjam/emailing
Composer 安装命令:
composer require trejjam/emailing
包简介
Send email over rabbitMQ
README 文档
README
Library for
- managing emails
- their groups
- send email to group(s)
- save email to IMAP
Installation
The best way to install Trejjam/Emailing is using Composer:
$ composer require trejjam/emailing
Configuration RabbitMq
Look how to configure Kdyby/RabbitMq This extension need only 'rabbitmq.connection'
extensions: rabbitmq: Kdyby\RabbitMq\DI\RabbitMqExtension rabbitmq: connection: default: host: localhost port: 5672 user: 'guest' password: 'guest' vhost: '/'
Configuration
.neon
extensions: emailing: Trejjam\DI\EmailingExtension emailing: tables : emails : table : send__emails id : id email : email groups : table : send__groups id : id parentId : parent_id name : name type : name : type options : [public, private] group_email : table : send__group_email id : id groupId : group_id emailId : email_id newsletter : name : newsletter options : [enable, disable] senders : table : send__sender id : id email : email configName : config_name connect : default : smtp : FALSE #TRUE - use SmtpMailer NULL - disable connection FALSE - use SendmailMailer host : NULL smtp_port : NULL username : NULL password : NULL secure : ssl imap : FALSE imap_host : TRUE #TRUE -> use host imap_port : 993 imap_param : /imap/ssl/validate-cert #Flags from http:#php.net/manual/en/function.imap-open.php imap_username : TRUE #TRUE -> use username imap_password : TRUE #TRUE -> use password other: ... rabbitmq : mailer : templateDir : '/presenters/templates/' defaultTemplate: 'emails/default.latte' imap : sendFolder : 'Sent.From web' producers : mailer : name : NULL #NULL -> use mailer connection : default exchange : NULL #NULL -> use mailer imap : name : NULL #NULL -> use imap connection : default exchange : NULL consumers : mailer : connection : default exchange : NULL queue : NULL imap : connection : default exchange : NULL queue : NULL cache : use : TRUE name : emailing timeout : 60 minutes
Config
The best way for configuration is using Kdyby/Console
$ composer require kdyby/console
Read how to install Kdyby/Console
php index.php
After successful installation display:
Available commands:
Emailing
Emailing:imap Basic IMAP task
Emailing:groups Edit groups
Emailing:install Install default tables
help Displays help for a command
list Lists commands
Config database
Create default tables:
php index.php Emailing:install
Config imap
List folders:
php index.php Emailing:imap [connectionName=default] -l
Add folder:
php index.php Emailing:imap [connectionName=default] -c folderName [-l]
Config groups
Add group:
php index.php Emailing:groups groupName [parentName] -c [-t type] [-l]
Move group:
php index.php Emailing:groups groupName [parentName] -m [-l]
Edit group:
php index.php Emailing:groups groupName -t type [-l]
Delete group:
php index.php Emailing:groups groupName -r [-l]
List all groups:
php index.php Emailing:groups -l
Config senders
Add sender:
php index.php Emailing:senders senderEmail [connection=default] -c [-l]
Change connection:
php index.php Emailing:senders senderEmail [connection=default] [-l]
Delete sender:
php index.php Emailing:senders senderEmail -r [-l]
List all senders:
php index.php Emailing:senders -l
Usage
Presenter/Model:
/** * @var \Trejjam\Emailing\RabbitMq\Mailer @inject */ public $rabbitMailer; /** * @var \Trejjam\Emailing\Emails @inject */ public $emails; /** * @var \Trejjam\Emailing\Groups @inject */ public $groups; /** * @var \Trejjam\Emailing\Senders @inject */ public $senders; function renderDefault() { $this->senders->addSender("email@from.ltd"); $this->senders->addSender("email2@from.ltd", "other"); $message=$this->rabbitMailer->createEmail(); $message->setSender("email@from.ltd"); //set from and connection $message->setImapSave(TRUE); $message->setTo("email@to.ltd"); $this->rabbitMailer->send($message); //send email generated by defaultTemplate, send using default connection, save email to IMAP $message->setSender("email2@from.ltd"); $message->setTemplate("newsletter.latte"); $message->setImapFolder("Sent.newsletter"); $message->setImapConnection("default"); $message->setUnsubscribeEmail("unsubscribe-1@from.ltd"); $message->setTo("email2@to.ltd"); $this->rabbitMailer->send($message); //send email generated by newsletter.latte, send using 'other' connection, save email to IMAP using 'default' $email = $this->emails->addEmail("email@to.ltd"); $email2 = $this->emails->addEmail("email2@to.ltd"); $all=$this->groups->addGroup("all"); $group = $this->groups->addGroup("newsletter", "all"); $this->emails->addEmailToGroup($email, $group); $this->emails->addEmailToGroup($email2, $all); foreach ($all->getEmailsRecursive() as $v) { dump($v->getEmail()); //email2@to.ltd, email@to.ltd } foreach ($all->getEmails() as $v) { dump($v->getEmail()); //email2@to.ltd } foreach ($group->getEmails() as $v) { dump($v->getEmail()); //email@to.ltd } dump($this->groups->getGroup("all")->containEmail($email)); //FALSE dump($this->groups->getGroup("newsletter")->containEmail($email)); //TRUE $this->emails->removeEmail("email@to.ltd", TRUE); $this->emails->removeEmail("email2@to.ltd", TRUE); }
trejjam/emailing 适用场景与选型建议
trejjam/emailing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 12 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「rabbitmq」 「nette」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 trejjam/emailing 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 trejjam/emailing 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 trejjam/emailing 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Work with RabbitMQ in Laravel.
Microservice RPC through message queues.
PHP AMQP Binding Library
Nette Framework adapter for I18n package
Build forms from schema
Extensible library for building notifications and sending them via different delivery channels.
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-28