• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Email scheduled task

  • Views Views: 14,001
  • Last updated Last updated:
  • Introduction​


    The email plugin will iterate over each record in the list defined in the plugin's general connection/list Options, and send an email out per record. This can be useful for notifying users.

    The Email scheduled task plugin will only run if the Fabrik Cron System Plug-in is installed.

    Options - details​


    cron-email-options.png


    • To - Email address to send the notification to - can use the table's record's data by using Placeholders e.g. {tablename___elementname}
    • Subject - The email subject - can use the table's record's data by using Placeholders e.g. {tablename___elementname}
    • Message - The email subject - can use the table's record's data by using Placeholders e.g. {tablename___elementname}
    • Eval- Evaluate the Message as PHP code
    • Condition - OPTIONAL PHP to evaluate for each row. The row will not be processed if you return false. Standard element Placeholders can be used, or row data can be accessed from $row array. Remember that this code runs on every row in the list, so keep your code efficient so you don't run in to max execution time issues.

    Options - Update​


    cron-email-update.png

    • Field - select a table's field to update
    • Value - select the value to update to
    • Eval - should we evaluate the update value.
    Update works well in conjunction with a prefilter on the selected list. For example your list may have a prefilter:


    where sent = 0


    In your update field you could select 'sent' and set the value to '1'.


    This would mean that the row is only processed once by the plug-in

    PHP Examples​

    Removing apostrophes from fields for proper html output. This will replace apostrophes of both types, straight and curled from the fields and replace them with encoded values, preventing any errors like "Message Body Empty" when attempting to run the email cron. Reminder: you need to turn Eval on for PHP code to work in the Message textarea.

    PHP:

    //removing apostrophe from fields...
    $personname = "{pfx_listname___name_raw}";
    $personname = preg_replace("/'/", "'", $personname);
    $personname = preg_replace("/?/", "'", $personname);

    //assign $output variable the email body html
    $output = '<p>The new subscriber '.$personname.' sent you a message, login to view it.</p>';

    //send $output back to Fabrik
    return $output;

    PHP Duration Example​

    PHP:

    $myDateElement = strtotime($row->date_time);
    $date = new DateTime();
    $datenow = $date->getTimestamp();
    $datediff = ($datenow - $myDateElement);
    $diff = round($datediff / 86400); //difference in days
    return ($diff == 10); // To send email on 10th day. Change this value to send nth day.
Back
Top