User Tools

  • Logged in as: anonymous (anonymous)
  • Log Out

Site Tools


Setting up Mail Queuing


Up to Mantis 1.0.x releases, emails were always sent synchronously. This means that when the user performs an action that triggers the sending of emails, the user had to wait till the emails are actually constructed and sent. The email queueing feature was first implement in Mantis 1.1.0a1 release.

Why email queuing

  • Flaky Email Servers: Sometimes email servers go down, this used to cause an error message to be prompted to the user and the notification to be lost. With email queueing the messages remain in the queue until they are sent successfully.
  • Bad configuration: If the administrator mis-configures the email settings, the user will get errors when emails are triggered and email notifications will be lost.
  • Performance: Typically there are several Mantis users who are notified for every change. An email is sent per user for the following reasons:
    • Different users may have different access levels and hence see different portions of the data.
    • Different users may have different language preference and hence need to get the emails in their preferred language.
    • Email addresses of users must not be disclosed (this can be achieved through bcc, but if emails are only sent to bcc, sometimes anti-spam don't like it).


The requirements to this feature were:

  • Improve performance by queuing emails and send them at a later time.
  • Provide a script can be executed from a cronjob to send the queued emails.
  • If email notifications fail, they should remain in the queue and must not be lost.
  • Emails targetted to invalid addresses must not be kept in the queue. A message is considered to be sent successfully as soon as it is delivered to the email server configured in Mantis, if the email server failed to send the message, it will send the NDR back to the email address configured in 'return_path_email' configuration item.
  • By default, the old behaviour for handling emails should be kept. Hence, users must configure queuing, otherwise all messages will be sent synchronously.

Configuring Queuing

  • Set 'email_send_using_cronjob' configuration item to ON.

Sending the Emails

Now that the emails are queued, we need to run the 'mantis/core/send_emails.php' regulary to send the emails. It is recommended to run this script every 1 to 5 minutes. In the example below, we will demonstrate how to run it every minute.

Following is the command line we need to execute:

php /path/to/mantis/scripts/send_emails.php

Following are the settings that determine how often it the script should run. In this case it's every minute:

Minute = *, Hour = *, Day = *, Month = *, Weekday = *

For hosted environments offering cPanel, the above information will be set after clicking “Cron jobs”, “Advanced (Unix Style)”. You will typically want to also provide your email as the address to which the cronjob output should be sent. This will help you to make sure that the script is running successfully. Once this is established, you should remove your email to avoid getting an email every minute.

In shared environments that supports cron jobs only with lynx, the check “send_emails.php is not allowed to run through the web server” possibly has to be modified. Bearing in mind that this change basically allows anyone knowing the URL to execute the script, which could potentially lead to DOS attacks move the script to a non-standard location or try to secure it so it can externally eg only be run from localhost or with .htaccess parameters.

Using the Windows Task Scheduler

Using the windows task scheduler is just as easy as using cron jobs. Just add a new task that is executing

/path/to/php-installation/php-cgi.exe /path/to/mantis/scripts/send_emails.php


Please add any comments or questions in this sections. Feel free to apply corrections or additions to the main body of the text.

mantisbt/setting_up_mail_queuing.txt · Last modified: 2013/10/04 12:15 by mahindra

CC Attribution-Noncommercial-Share Alike 4.0 International Driven by DokuWiki