Notifications and cron

Xcomm3x2 min readPage 8 of 11
On this page 2

Notifications are not sent synchronously when a comment is posted — they are put in a queue (xcomm3x_mail_queue). Sending is done by the cron script core/components/xcomm3x/cron/send_mail_queue.php.

Channels:

  • manager — an email to the address from xcomm3x.notify_manager_email
  • resource_author — an email to the page author (if enabled in the settings)
  • parent_author — an email to the author of the comment that was replied to (on by default)

The manager channel cannot be unsubscribed from. The other channels can; before sending, the script checks the xcomm3x_mail_unsubscribe table.

On error: up to 3 sending attempts. After 3 failures the email status becomes failed (2). It can be resent manually from the “Email queue” tab of the manager page.

Email templates are MODX chunks. Chunk names are set in the component system settings. Available placeholders: site_name, resource_title, resource_url, comment_id, author_name, author_email, text, comment_date, unsubscribe_url.

Notifications and moderation

The manager gets an email when a comment is waiting for moderation or is published right away. The page author and the parent comment author get an email only after publication. No emails are sent about spam. If an author edits a published comment while pre-moderation is on, the comment goes back to moderation.

Cron — sending email notifications

Email notifications are queued when a comment is posted. A cron job is needed to actually send them.

Script path:

core/components/xcomm3x/cron/send_mail_queue.php

Example cron entry (every 5 minutes):

*/5 * * * * /usr/bin/php /var/www/site/core/components/xcomm3x/cron/send_mail_queue.php

What the script does:

  • Processes up to 50 emails per run
  • Retries on failure, at most 3 times; after that the status becomes failed
  • Checks the unsubscribe table before sending — emails to unsubscribed users are skipped
  • The manager channel cannot be unsubscribed from

Monitoring: the “Email queue” tab of the component shows the status of each email. Emails with the “Error” status can be resent manually.

Besides the Russian ones, English email chunks xcomm3x_mail_en_* are included — set them in the xcomm3x.tpl_* settings. Cron deletes sent and skipped emails after xcomm3x.mail_queue_keep_days days. The script only runs from the command line.