mothership-ec / cog-mothership-mailing
该包已被弃用且不再维护。没有建议的替代包。
邮件发送的Mothership模块,支持与流行的第三方系统同步
1.1.0
2015-12-02 13:50 UTC
Requires
- php: >=5.4.0
- mothership-ec/cog: ~4.0
- mothership-ec/cog-mothership-reports: ~2.2
- mothership-ec/cog-mothership-user: ~4.0
Suggests
- mothership-ec/cog-mothership-campaign-monitor: Allows Campaign Monitor integration
This package is not auto-updated.
Last update: 2021-03-22 11:07:26 UTC
README
Message\Mothership\Mailing
模块提供了用户决定是否订阅接收营销邮件的功能。
该模块只提供了与第三方电子邮件营销软件集成的框架,但不包含任何原生支持。
集成第三方软件
实现AdapterInterface
要集成第三方软件,必须创建一个实现了Message\Mothership\Mailing\ThirdParty\Sync\AdapterInterface
接口的类。
该接口包含以下方法
getName()
- 此方法必须返回一个字符串,表示适配器在集合和mailing.yml
配置中的引用getAllSubscribers(\DateTime $since = null)
- 此方法应连接到第三方软件并收集所有现有的订阅者(即使他们已退订)。如果提供了Datetime
实例,则应仅返回自那时以来已修改的电子邮件地址。getSubscriber($email)
- 此方法应从第三方获取特定电子邮件地址的详细信息subscribe(\Message\Mothership\Mailing\SubscriberInterface $subscriber)
- 此方法应将电子邮件地址订阅到营销活动。该模块附带实现了Message\Mothership\Mailing\SubscriberInterface
接口的Message\Mothership\Mailing\Subscription\Subscriber
类。该类包含有关订阅者的基本信息,可以保存到和从数据库加载unsubscribe(\Message\Mothership\Mailing\SubscriberInterface $subscriber)
- 此方法应从营销活动中取消订阅电子邮件地址isSyncable()
- 此方法确定是否可以自动同步存储在数据库中的订阅者信息与第三方软件。如果返回false,则电子邮件地址需要手动订阅
实现第三方适配器
一旦您编写了第三方适配器类,您需要通过服务容器将其添加到适配器集合中。
为此,扩展mailing.sync.adapter.collection
服务并添加它,如下所示
$services->extend('mailing.sync.adapter.collection', function ($collection, $c) { // Where 'MyAdapterClass' is the third party adapter that implements // the AdapterInterface $collection->add(new MyAdapterClass); return $collection; });
然后,您需要将getName()
方法的返回值添加到mailing.yml
文件中,如果它返回'my-adapter',则配置将如下所示
sync:
enabled: false
adapter: my-adapter
与第三方同步
此模块每小时通过cron与第三方软件同步一次。要启用此功能
- 您必须确保适配器类的
isSyncable()
方法返回true
。 - 然后,您应确保在
mailing.yml
文件中启用它
sync:
enabled: true
adapter: my-adapter
- 您必须在服务器上设置
crontab
以运行所有Mothership计划任务。这不仅仅用于邮件,应在所有Mothership安装上设置。但是,要设置它,请在终端中运行crontab -e
,然后添加以下行
# Fill in the path as applicable
* * * * * /[path to your installation]/bin/cog task:run_scheduled --env=live > /dev/null`