Code Monkey home page Code Monkey logo

thirdsetmautictimingbundle's Introduction

ThirdSetMauticTimingBundle

Description

The ThirdSetMauticTimingBundle is a Mautic plugin that allows you to set a cron timing expression on any Campaign action event (such as a "Send Email" action).

Purpose

For example, you could add a cron expression that only allows sending on weekdays during working hours in New York.

Compatibility

This plugin works on Mautic 2.x, Mautic 3.x and Mautic 4.x. It should work on most versions of PHP.

Mautic 4.x

This plugin has been tested with up to Mautic v4.3.1.

Mautic 3.x

This plugin has been tested with up to Mautic v3.2.1.

Mautic 2.x

This plugin has been tested with up to Mautic v2.16.0.

PHP

This plugin has been tested with up to PHP v7.4.29.

Features

  • Adds the full ability of cron syntax to your campaign actions allowing you to only send emails at certain times.
  • Use different cron expressions on different campaign actions.
  • Enter a timezone to use when evaluating the cron expression (this allows you to send an email during working hours in your own timezone, for example).
  • Use different time zones for different cron expressions/campaign actions.
  • Use the Contact's time zone (if available) to evaluate the cron expression. It will fall back to use any time zone you specify (or the System Default time zone) if the Contact's time zone isn't known.

Installation

  1. Download or clone this bundle into your Mautic /plugins folder.
  2. Manually delete your cache (var/cache/prod for Mautic 3.x+ and app/cache/prod for Mautic 2.x).
  3. In the Mautic GUI, go to the โš™๏ธ icon in the top right and then to Plugins.
  4. Click the "Install/Upgrade Plugins" button in the top right. Note: if you are on an older version of Mautic, click the drowpdown arrow in the top right and then choose "Install/Upgrade Plugins".
  5. You should now see the Timing plugin in your list of plugins.
  6. Run the following console commands to update the database:
php bin/console doctrine:schema:update --dump-sql
php bin/console doctrine:schema:update --force

Note: For Mautic 2.x, replace php bin/console with php app/console in the above commands.

Usage

Timing

After installing the plugin, you will now see a new Timing section when adding or editing Campaign actions.

Expression Field

The expression field allows you to enter a cron expression for the timing to be evaluated against. See the Wikipedia Cron Page for a good overview of cron syntax.

Note that it is best to use ranges (ex: "1-5") instead of exact values. This is because the expression is evaluated when the campaign is triggered and when that happens is external to this plugin.

Example:

* 09-17 * * 1-5 (Weekdays, 9AM to 5PM)

Use Contact's Time Zone Field

When this field is enabled, the plugin will evaluate the cron expression off of the Contact's time zone. This allows you to only send emails during the Contact's working hours.

The contact time zone is evaluated in the following order:

  1. The timezone field of the contact (e.g. mautic.lead.field.timezone) (Mautic > 2.6.1), else:
  2. The timezone of the last ip address used by the contact, else:
  3. The value of the Time Zone Field in the action, else:
  4. The system default time zone

Time Zone Field

If a time zone is specified in this field, the cron expression will evaluate against the selected time zone. This allows you to do things such as only sending emails during your working hours.

If you've enabled the "Use Contact's Time Zone" field, the contact's time zone would be used instead of this field (unless the Contact's time zone is unknown in which case the plugin will fall back to the time zone specified here).

Testing the Plugin

This plugin includes a suite of unit tests. You will need to have PHPUnit installed in order to run the tests.

Installing PHPUnit on AlpineLinux

apk update && apk add ca-certificates && update-ca-certificates && apk add openssl
/usr/bin/wget https://phar.phpunit.de/phpunit.phar -O /usr/bin/phpunit && chmod 755 /usr/bin/phpunit

Installing PHPUnit on Debian Linux

curl https://phar.phpunit.de/phpunit.phar -L -o /usr/bin/phpunit && chmod 755 /usr/bin/phpunit

Running the Tests

Change directories into the plugin dir (cd plugins/ThirdSetMauticTimingBundle) and then run:

phpunit

Or for older versions of Mautic (<4.0), run:

phpunit --bootstrap ../../app/autoload.php

Credits

This plugin is developed and maintained by Third Set Productions the makers of AdPlugg.

Disclaimer

This plugin is licensed under GPLv3.

The GPL clearly explains that there is no warranty for this free software. Please see the included license.txt file for details.

thirdsetmautictimingbundle's People

Contributors

collinkrawll avatar indorock avatar regevbr avatar sagistrauss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

thirdsetmautictimingbundle's Issues

Undefined offset: 0 in HoursField.php

I set up a campaign which goal is to send specific e-mail depending on the time of the day. I noticed e-mails are not sent.

When triggering campaign with

php app/console mautic:campaigns:trigger

I get:

PHP Notice: Undefined offset: 0 in /plugins/ThirdSetMauticTimingBundle/ThirdParty/Cron/HoursField.php on line 55

Any ideas what goes wrong? ;)

Can't install.

Hello,

After uploading the package to the plugins folder, clearing the cache folder , the plugin doesn't install.
Upon pressing the install/upgrade plugins, the folloding message shows: 0 new plugins were installed and 0 updated.

Mautic Version used is 2.8.2.

Table campaign_events_timing is not created

When I'm saving the campaign, I get the following error:

[2017-04-18 04:25:14] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\TableNotFoundException: "An exception occurred while executing 'INSERT INTO campaign_events_timing (expression, use_contact_timezone, timezone, event_id) VALUES (?, ?, ?, ?)' with params ["* 09-17 * * 1-5", 0, null, 1]: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.campaign_events_timing' doesn't exist" at /var/www/mautic/mautic-2.7.1/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 53 {"exception":"[object] (Doctrine\DBAL\Exception\TableNotFoundException(code: 0): An exception occurred while executing 'INSERT INTO campaign_events_timing (expression, use_contact_timezone, timezone, event_id) VALUES (?, ?, ?, ?)' with params ["* 09-17 * * 1-5", 0, null, 1]:\n\nSQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.campaign_events_timing' doesn't exist at /var/www/mautic/mautic-2.7.1/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:53, Doctrine\DBAL\Driver\PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.campaign_events_timing' doesn't exist at /var/www/mautic/mautic-2.7.1/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:93, PDOException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mautic.campaign_events_timing' doesn't exist at /var/www/mautic/mautic-2.7.1/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:91)"} []

Looks like the table is not created. Is there anything special I need to do to get the tables setup?

I checked with doctrine:migrations:status and it reports "Already at latest version".

Thanks.

Cannot install?!

Hi

I cannot install the plugin.

  1. Downloaded the bundle, unzip and copied to Mautic /plugins folder.
  2. Delete cache (app/cache/prod).
  3. Set folder to 755 rights
  4. In the Mautic GUI, clicked "Install/Upgrade Plugins"
    ... nothing happend.

Any idea?

Translation ready

Hello folks ... thanks a lot for this great plugin.

How.can we make this translatable?

I hope providing an .ini file for string literals a great way

thanks in advance

Issues with large campaign on 2.10.1?

Q|A

Anyone have an issue when executing large campaigns? The process been very slow in mautic leading to process taking a much longer time to process and emails are going out overnight and in the weekend outside the crontabs which are set 8-6..

Problem appeared since mautic 2.9 and we are unsure if its mautic or timing bundle..

A reference to the thread is here: mautic/mautic#4687

User timezone should also be evaluated from user details

The user timezone is realized by the ip addresses associated with the user, but in our use case, users are created and updated solely by our api, and as such, users don't have an ip address associated with them, and we set the timezone per user using the api - we need to be able to use that field

When using with A/B split test emails, both variants are sent to the contact

Issue:
If there is a cron expression on a "send email to contact" event set to send an email with A/B variants, both variants are sent to the contact.

Reproduce:
Create a campaign with a "send email to contact" event set to send an email with A/B variant.
Put a contact through the campaign.
Both emails will be sent to the contact.

Not working on 2.14?

I just set up the plugin and have been testing it out, however all timing settings are completely ignored.

screenshot_146

The timing settings should limit this email from sending only on Sunday, Saturday, and Wednesday between 11am and 3pm. However, the email gets sent whenever the cron job runs, as if the plugin doesn't exist. For example, 5pm on a Friday.

I have updated all database schema etc with no errors. Can anyone confirm this issue quickly please? Really need this resolved asap. No errors in log.

My email settings are set to queue.

And here are my cron jobs:
screenshot_147

I also ran the phpunit tests and everything came back OK:
screenshot_148

Mysql database shows the timing settings where in fact saved:
screenshot_149

Thanks for your time.

Clarification on the timezone

Hiya,

Thanks for the plugin just trying to understand if I got this right...

I got contacts without timezones but location ips

So if I want to send emails only during Sat Sun Mon 10-13 I set the expression to

  • 10-13 * * 1,6,7

And tick Contact's Time Zone

As it's supposed to fall back on the last ip address right?

Getting a warning

Not sure what the consequences are, but I am getting the following warning:

$> ./app/console cache:clear

PHP Warning: Declaration of MauticPlugin\ThirdSetMauticTimingBundle\Model\TimingModel::getEntity(Mautic\CampaignBundle\Entity\Event $event = NULL) should be compatible with Mautic\CoreBundle\Model\AbstractCommonModel::getEntity($id = NULL) in /var/www/mautic/mautic-2.7.1/plugins/ThirdSetMauticTimingBundle/Model/TimingModel.php on line 76

Thanks.

mautic.ERROR : CAMPAIGN: is not a valid CRON expression [] []

I'm getting mautic.ERROR : CAMPAIGN: is not a valid CRON expression [] [] in my log whenever my campaign tries to run. The thing is, I have not set any timings for this campaign at all. Looks like it's trying to evaluate timing on events where timing hasn't even been set.

The associated events will not fire when this occurs.

It's coming from the CronExpression.php file in this plugin, only started after the latest plugin update. Running 2.14.0

Broken tracking link

Oddly enough, the tracking link seems to be affected by the plugin.

When I click on the tracking link in the email, e.g.:

https://domain.com/r/65290d53a660fa3fb1e...JlbWFpbCI7aTozO319

I get the following error in the log:

[2017-04-20 15:57:39] mautic.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function format() on null - in file /vagrant/mautic-2.7.1/plugins/ThirdSetMauticTimingBundle/Helper/TimingHelper.php - at line 94 [] []

And of course the landing page fails to load.

Thanks.

Please clarify the settings for a marketing email use case

I can't make this plugin work on Mautic 3. Could you clarify the settings for a marketing email use case?

I have set a campaign with emails of type "Marketing".

My contacts all have their time zone set and they are located all over the world on different timezones.

Under Configurations > Email settings > How should email be handled? I have selected "Queue".

Within my campaign, the sending of email is configured as follows:

  • Execute this event.. = Inmediatelly
  • Email type = Marketing
  • Timing > Expression = * 09-17 * * 1-5
  • Timing > Use Contact's Time Zone? = Yes

When I run mautic:campaigns:trigger all messages are placed inmediatelly in the filesystem queue inside var/spool.

Later, when I run mautic:emails:send all messages go out to the SMTP server and they are removed from var/spool.

I would expect that only the emails directed to contacts within their current bussines hours would be generated and placed under the filesystem queue.

Could it be possible that this plugin isn't supposed to be used with filesystem queue?

Could it be possible that this pluging isn't for marketing emails, but rather for transactional emails?

Thank you for your work.

Does not work with Mautic 4

I have this in my logs
mautic.NOTICE: PHP Notice - date_default_timezone_set(): Timezone ID '' is invalid - in file /var/www/www-root/data/www/mautic/app/bundles/CoreBundle/EventListener/EnvironmentSubscriber.php - at line 58

It sends emails based on the contacts timezone. Despite the plugin settings in the event.

upd: Next day the PHP Notice disappeared and everything works well. Magic!

Can't copy timer settings when cloning campaign

The timing information saved as in "Send email" action failed to be copyied when a campaign is cloned. As result, it all must be set again.

  1. How to replicate
  2. Create a new campaign
  3. Plug an email "Send email" action and set something in ThirdSetMauticTimingBundle (working days + contact timezone YES)
  4. Save this campaign
  5. Clone this campaign

Actual result : The information saved as ThirdSetMauticTimingBundle failed to be cloned

Mautic version 2.12.2
PHP version 5.6.32

Error log :

14/15 [==========================>-]  93%PHP Fatal error:  __clone method called on non-object in /var/www/web-mautic/plugins/ThirdSetMauticTimingBundle/Helper/TimingHelper.php on line 140


  [Symfony\Component\Debug\Exception\FatalErrorException]
  Error: __clone method called on non-object


Exception trace:
 () at /var/www/web-mautic/plugins/ThirdSetMauticTimingBundle/Helper/TimingHelper.php:140

Campaign won't save timing info - gives the following error

I have the ThirdSetMauticTimingBundle installed but and did everything in the instructions but am getting the following error when simply clicking the work hours on a campaign and then saving it:

mautic.NOTICE: PHP Notice - Undefined index: timing - in file ../mautic/plugins/ThirdSetMauticTimingBundle/EventListener/DoctrineSubscriber.php - at line 97 [] []

Change are not saved in the campaign and this is the error I get. Any ideas how to get this plugin working correctly.

Please help me solve this!
Thank you!

Plugin is not seen in Mautic 2.12.0 upgrade

Did the update schema by CLI and saw that it forced the update but I still don't see it in the list of plugins and the field does not appear when editing campaign actions.

Plugin not detected by Mautic 2.11

Uploaded ThirdSetMauticResetBundle-Master bundle and unzipped package.
Cleared Cache.
Tried to install plugin via Mautic but plugin not detected.
-> Renamed Bundle ThirdSetMauticResetBundle
Cleared cache plugin still not detected.
-> Renamed ThirdSetMauticResetBundle to MauticThirdSetMauticResetBundle (to keep naming convention).
Still not detected.

My System
Amazon EC2 Ubuntu 16.04 + Serverpilot and with SSL cert.

What is the difference between this plugin and Relative Time Period

When configuring the sending of an email with a campaign, I see the option to use a relative time period which allows selecting weekdays and hours.

image

It looks like if I select the options above and I set the number of days to = 0, it is probably the same as using this plugin.

image

Could you clarify the difference?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.