Product SiteDocumentation Site

5.8. Email

MantisBT sends email notifications to users when certain events occur. This section includes configuration relating to when to trigger email notifications, how to send them, from what addresses to send them, and how to format them.
The default implementation uses PHPMailer to send emails which is implemented via core/classes/EmailSenderPhpMailer.class.php. Such implementation can be overriden by EmailSender plugins, see TestEmailSender for an example.
$g_webmaster_email
The webmaster's e-mail address. This address is displayed in the bottom of all MantisBT pages. webmaster@example.com
$g_from_email
The email address to be used as the source of all emails sent by MantisBT. noreply@example.com
$g_from_name
The sender name of all emails sent by MantisBT. Mantis Bug Tracker
$g_return_path_email
Email address to receive bounced emails.
$g_enable_email_notification
Set to ON to enable email notifications, OFF to disable them. Default is ON. Note that disabling email notifications has no effect on emails generated as part of the user signup process. When set to OFF, the password reset feature is disabled. Additionally, notifications of administrators updating accounts are not sent to users.
$g_email_notifications_verbose
When enabled, the email notifications will include the full issue with a hint about the change type at the top, rather than using dedicated notifications that are focused on what changed. This change can be overridden in the database per user. Default is OFF.
$g_default_notify_flags
Sets the default email notifications values for different user categories.
In combination with $g_notify_flags, this config option controls who should get email notifications on different actions/statuses. See Section 7.4, “Email Notifications” for examples of customizing the notification flags.
The user categories are:
  • reporter: the Issue's reporter
  • handler: the user assigned to the Issue
  • monitor: users who are monitoring the Issue
  • bugnotes: users who have added a bugnote to the Issue
  • category: category owners
  • explicit: users who are explicitly specified by the code based on the action (e.g. user added to monitor list).
  • threshold_min and threshold_max are used to send messages to all members of the project whose access level is
    • greater than or equal to threshold_min, and
    • less than or equal to threshold_max.
    To send notifications to everyone, set threshold_min to ANYBODY and threshold_max to NOBODY. To send to all DEVELOPERS and above, use DEVELOPER and NOBODY respectively.
$g_notify_flags
Sets notifications overrides for specific actions/statuses.
If a user category is not listed for an action, the default defined by$g_default_notify_flags is used.
Available actions include:
  • new: a new Issue has been added
  • reopened: an Issue has been reopened
  • deleted: an Issue has been deleted
  • owner: an Issue has been assigned to a new owner
  • bugnote: a bugnote has been added to a bug
  • sponsor: the sponsorship for the Issue has changed (added, deleted or updated)
  • relation: a relationship for the Issue has changed (added, deleted or updated)
  • monitor: a user is added to the monitor list.
  • status: A status code, as defined in $g_status_enum_string, (see Section 5.24, “Misc”). For example: resolved, closed, feedback. acknowledged, etc.

    Note

    Spaces in the status code are replaced with underscores ('_') when creating the action.
For example, the following code overrides the default by disabling notifications to bugnote authors and users monitoring the bug when acknowledging a new bug:
$g_notify_flags['acknowledged'] = array(
	'bugnotes' => OFF,
	'monitor' => OFF,
);
See Section 7.4, “Email Notifications” for further examples of customizing the notification flags.
$g_email_receive_own
This defines whether users should receive emails for their own actions. This option is defaulted to OFF, hence, users do not receive email notification for their own actions. This can be a source for confusions for users upgrading from MantisBT 0.17.x versions, since in these versions users used to get notified of their own actions.
$g_validate_email
Determines whether email addresses are validated.
When ON (default), validation is performed using the pattern given by the HTML5 specification for email type form input elements. When OFF, validation is disabled.

Note

Regardless of how this option is set, validation is never performed when using LDAP email (i.e. when $g_use_ldap_email = ON, see Section 5.21.2, “LDAP authentication method parameters”), as we assume that it is handled by the directory.
$g_check_mx_record
Set to OFF to disable email checking. Default is OFF.
$g_allow_blank_email
If ON, allows the user to omit an email address field. If you allow users to create their own accounts, they must specify an email at that point, no matter what the value of this option is. Otherwise they wouldn't get their passwords.
Administrators are able to bypass this check to enable them to create special accounts like anonymous access and other service accounts that don't need notifications.
$g_email_login_enabled
Allow login with email address.
When this is ON, users can log in with their registered email address, in addition to their username.
This will only work as long as there is a single user with the specified email address, and the email address is not blank.
The default value is OFF.
$g_email_ensure_unique
When enabled, the uniqueness of email addresses will be enforced for new users as well as updates to existing ones. Default is ON.

Warning

When this setting changes from OFF to ON (which will de facto occur when upgrading to MantisBT 1.3.0 or later from an older version), there could be existing user accounts sharing the same email address.
It important that such duplicates are identified and fixed, to avoid unexpected and unpredictable behavior when looking up users with their email address, as the system expects them to be unique.
To facilitate this task, the Administration Checks will detect duplicate email addresses and identify the related user accounts. A warning will also be displayed in the Manage Users page (see Section 6.8.1, “Users”) and when editing a user account whose email address is associated with one or more other accounts.
$g_limit_email_domains
Only allow and send email to addresses in the given domain(s). This is useful as a security feature and it is also useful in cases like Sourceforge where its servers are limited to only sending emails to SourceForge email addresses in order to avoid spam. $g_limit_email_domains = array( 'users.sourceforge.net', 'sourceforge.net' );
$g_show_user_email_threshold
This specifies the access level that is needed to have user names hyperlinked with mailto: links. The default value is NOBODY, hence, even administrators won't have this feature enabled.
$g_show_user_realname_threshold
This specifies the access level that is needed to see realnames on user view page. The default value is NOBODY, hence, even administrators won't have this feature enabled.
$g_phpMailer_method
Select the method to send mail:
  • PHPMAILER_METHOD_MAIL for use of PHP built-in mail() function,
  • PHPMAILER_METHOD_SENDMAIL for "sendmail" (or any sendmail-compatible mail transfer agent, e.g. postfix, DMA, etc.),
  • PHPMAILER_METHOD_SMTP for SMTP.
Default is PHPMAILER_METHOD_MAIL because, despite of its issues, PHP's mail() function has the advantage of being cross-platform (e.g. no sendmail on Windows) and as long as PHP is configured properly it will generally work out-of-the-box. On UNIX-like operating systems, it is usually better to use a different option.
$g_smtp_host
This config option is specific to PhpMailer provider.
This option specifies the SMTP server to submit messages to. The SMTP server (MTA) then takes on the responsibility of delivering messages to their final destinations.
To use the local SMTP (if available) set this to 'localhost', otherwise use the fully qualified domain name of the remote SMTP server.
It can be either a single hostname, or multiple semicolon-delimited hostnames. You can specify for each host a port other than the default, using format: hostname:port (e.g. "smtp1.example.com:25;smtp2.example.com").
Hosts will be tried in the given order.

Note

This is only used with PHPMAILER_METHOD_SMTP (see $g_phpmailer_method).
The default is 'localhost'.
$g_smtp_port
This config option is specific to PhpMailer provider.
The default SMTP port to use. This can be overridden individually for specific hosts. (see $g_smtp_host).
Typical SMTP ports are 25 and 587.
The default is 25.
$g_smtp_connection_mode
This config option is specific to PhpMailer provider.
Allow secure connection to the SMTP server. Valid values are:
  • '' (empty string): No encryption. This is the default.
  • ssl
  • tls
$g_smtp_username
This config option is specific to PhpMailer provider.
SMTP Server Authentication user
Allows the use of SMTP Authentication when using a remote SMTP host.

Note

must be set to '' (empty string) if the SMTP host does not require authentication.
Default is ''.
$g_smtp_password
This config option is specific to PhpMailer provider.
This is the password that is used in SMTP Authentication. Not used when $g_smtp_username = ''
Default is ''.
$g_email_retry_in_days
Duration (in days) to retry failed emails before deleting them from queue. Default 7 days.
$g_email_send_using_cronjob
Use a cron job or task scheduler to send emails.
When OFF (default), emails are sent as soon as an action is performed. The user will have to wait for MantisBT to process the email queue after each page load.
It is recommended to set this to ON. In that case, an external utility, typically a cron job or a scheduler task, must be set up by the system admin to execute the provided script scripts/send_emails.php at regular intervals (e.g. every few minutes). This script can only be run from the CLI, not from the web interface, for security reasons.

Note

Processing the email queue can take a significant amount of time on systems generating large numbers of notifications, when the queue contains many undeliverable emails or when mail delivery is slow. Enabling this option can significantly improve MantisBT's performance.
$g_email_separator1
Default is str_pad('', 70, '='); This means 70 equal signs.
$g_email_separator2
Default is str_pad('', 70, '-'); This means 70 minus signs.
$g_email_padding_length
Default is 28.
MantisBT uses flags and a threshold system to generate emails on events. For each new event, email is sent to:
  • the reporter, qualified by the notify flag 'reporter' below
  • the handler (or Assigned to), qualified by the notify flag 'handler' below
  • anyone monitoring the bug, qualified by the notify flag 'monitor' below
  • anyone who has ever added a bugnote the bug, qualified by the notify flag 'bugnotes' below
  • anyone assigned to the project whose access level is greater than or equal to the notify flag 'threshold_min' and less than or equal to the notify flag 'threshold_max' below
From this list, those recipients who meet the following criteria are eliminated:
  • the originator of the change, if $g_email_receive_own is OFF
  • the recipient either no longer exists, or is disabled
  • the recipient has turned their email_on_<new status> preference OFF
  • the recipient has no email address entered

5.8.1. DKIM signature

These config options are specific to PhpMailer provider.
In order to setup DomainKeys Identified Mail (DKIM) Signatures (as defined in RFC 6376), you need to enable the feature (see $g_email_dkim_enable), and provide at least:
  • Domain (see $g_email_dkim_domain),
  • Private key or key file path (see $g_email_dkim_private_key_file_path and $g_email_dkim_private_key_string),
  • Selector (see $g_email_dkim_selector),
  • Identity (see $g_email_dkim_identity).
$g_email_dkim_enable
Enables DomainKeys Identified Mail (DKIM).
The default is OFF.
$g_email_dkim_domain
Defines the domain for DKIM Signatures.
This is typically same as the host part of the $g_from_email. For example example.com.
$g_email_dkim_private_key_file_path
Path to the private domain key to be used for DKIM Signatures.
If the key is specified in $g_email_dkim_private_key_string this setting will not be used.
$g_email_dkim_private_key_string
Private domain key to be used for DKIM Signatures.
This string should contain private key for signing. Leave empty string if you wish to load the key from the file defined with $g_email_dkim_private_key_file_path.
$g_email_dkim_selector
Selector to be used for DKIM Signatures.
If your domain is example.com, typically DNS TXT field should have: host: mail.example._domainkey, value: v=DKIM1; t=s; n=core; k=rsa; p=[public key]. In this case selector should be mail.example
$g_email_dkim_passphrase
Private DKIM domain key password.
Leave empty string if your private key does not have password
$g_email_dkim_identity
Identity to be used for DomainKeys Identified Mail (DKIM) Signatures.
This is usually the same as $g_from_email. For example, noreply@example.com