定制 mailmotor/mailmotor-bundle 二次开发

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

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

mailmotor/mailmotor-bundle

最新稳定版本:4.0.3

Composer 安装命令:

composer require mailmotor/mailmotor-bundle

包简介

This Symfony bundle loads in MailMotor as a service. So you can subscribe/unsubscribe members to any mailinglist managing API. F.e.: MailChimp, CampaignMonitor, ...

README 文档

README

Latest Stable Version License Build Status Scrutinizer Code Quality

Subscribing/Unsubscribing to your own mailinglist has never been this easy! Thanks to this Symfony bundle.

Installation

How to configure MailChimp

composer require mailmotor/mailchimp-bundle
// In `app/AppKernel.php` public function registerBundles() { $bundles = array( // ... new MailMotor\Bundle\MailMotorBundle\MailMotorMailMotorBundle(), new MailMotor\Bundle\MailChimpBundle\MailMotorMailChimpBundle(), );
# In `app/config/parameters.yml` parameters: # ... mailmotor.mail_engine: 'mailchimp' # or another mailmotor engine mailmotor.api_key: xxx # enter your mailchimp api_key here mailmotor.list_id: xxx # enter the mailchimp default list_id here

Examples

Subscribing

$this->get('mailmotor.subscriber')->subscribe( $email, // f.e.: 'info@jeroendesloovere.be' $language, // f.e.: 'nl' $mergeFields, // f.e.: ['FNAME' => 'Jeroen', 'LNAME' => 'Desloovere'] $interests, // f.e.: ['9A28948d9' => true, '8998ASAA' => false] $doubleOptin, // OPTIONAL, default = true $listId // OPTIONAL, default listId is in your config parameters );

Unsubscribing

$this->get('mailmotor.subscriber')->unsubscribe( $email, $listId // OPTIONAL, default listId is in your config parameters );

Exists

$this->get('mailmotor.subscriber')->exists( $email, $listId // OPTIONAL, default listId is in your config parameters );

Is subscribed

$this->get('mailmotor.subscriber')->isSubscribed( $email, $listId // OPTIONAL, default listId is in your config parameters );

Full example for subscribing

use MailMotor\Bundle\MailMotorBundle\Exception\NotImplementedException; // Don't forget to add validation to your $email $email = 'info@jeroendesloovere.be'; try { if ($this->get('mailmotor.subscriber')->isSubscribed($email)) { // Add error to your form } // Fallback for when no mailmotor parameters are defined } catch (NotImplementedException $e) { // Do nothing } if ($noErrors) try { // Subscribe the user to our default group $this->get('mailmotor.subscriber')->subscribe( $email, $language, $mergeFields ); // Fallback for when no mailmotor parameters are defined } catch (NotImplementedException $e) { // Add you own code here to f.e.: send a mail to the admin } }

Full example for unsubscribing

use MailMotor\Bundle\MailMotorBundle\Exception\NotImplementedException; // Don't forget to add validation to your $email $email = 'info@jeroendesloovere.be'; try { // Email exists if ($this->get('mailmotor.subscriber')->exists($email)) { // User is already unsubscribed if ($this->get('mailmotor.subscriber')->isUnsubscribed($email)) { // Add error to your form: "User is already unsubscribed" } // Email not exists } else { // Add error to your form: "email is not in mailinglist" } // Fallback for when no mailmotor parameters are defined } catch (NotImplementedException $e) { // Do nothing } if ($noErrors) { try { // Unsubscribe the user $this->get('mailmotor.subscriber')->unsubscribe($email); // Fallback for when no mailmotor parameters are defined } catch (NotImplementedException $e) { // We can send a mail to the admin instead } }

Extending

Creating a bundle for another mail engine.

F.e.: You want to use a mail engine called "Crazy".

public function registerBundles() { $bundles = array( // ... new Crazy\Bundle\MailMotorBundle\CrazyMailMotorBundle(), );

In app/config/parameters.yml

mailmotor.mail_engine: 'crazy' mailmotor.api_key: xxx # enter your crazy api_key here mailmotor.list_id: xxx # enter the crazy default list_id here

Then you just need to duplicate all files from another mail engine, like f.e.: "mailmotor/mailchimp-bundle" and replace all the logic for your own mail engine.

Credits

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固