A cross-platform background service (Windows Service / systemd daemon) that processes the outgoing mail queue for MantisBT.
MantisBT's PHP-based mail subsystem can be difficult to configure correctly in some environments. This project replaces it with a standalone .NET hosted service that reads pending notifications directly from the MantisBT database and sends them via email, making the process easier to configure, run, and debug.
The original implementation sent mail over SMTP; that version is preserved on the SMTP_Client branch. The current version uses Microsoft.Graph to send mail through Exchange Online.
- Access to the MantisBT database
- An Azure AD app registration with permissions to send mail via Microsoft Graph (
Mail.Send), used to obtain theTenantId,ClientId, andClientSecretbelow
-
Disable mail delivery from the MantisBT web application by adding the following line to your
config_inc.php, which defers mail sending to this service instead:$g_email_send_using_cronjob = ON;
-
Download the latest release artifact from the Releases page:
MantisBTMailTask-<version>-win-x64.zipfor Windows — a win-x64 build that includesMantisBTMailTask.exeMantisBTMailTask-<version>.zip/MantisBTMailTask-<version>.tgzfor Linux — a framework-dependent build (requires the matching .NET runtime to be installed) that also includes the sample systemd unit file
These are built and published automatically by the project's GitHub Actions release workflow.
-
Extract the archive contents to the location you want to run the service from. The archive includes
appsettings.jsonand, for Linux, the samplemantisbtmailtask.serviceunit file. -
Update
appsettings.jsonwith your environment's configuration (see Configuration below). Only the minimum required settings are included in the default file. -
Install the service for your operating system:
Windows
sc create MantisBTMailTask BinPath=<INSTALL FOLDER>\MantisBTMailTask.exe sc start MantisBTMailTask
Linux
A sample unit file is provided at
mantisbtmailtask.service. Copy the published files to/opt/mantisbtmailtask(or update the paths in the unit file to match your install folder), then run:sudo useradd --system --no-create-home --shell /usr/sbin/nologin mantisbtmailtask sudo cp mantisbtmailtask.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable --now mantisbtmailtask sudo systemctl status mantisbtmailtask
Settings are read from appsettings.json.
| Section | Key | Description | Default |
|---|---|---|---|
MantisDB |
Host |
MantisBT database hostname | localhost |
MantisDB |
Port |
MantisBT database port | 3306 |
MantisDB |
Database |
MantisBT database name | (required) |
MantisDB |
Username |
MantisBT database username | (required) |
MantisDB |
Password |
MantisBT database password | (required) |
MailServer |
TenantId |
Azure AD tenant ID | (required) |
MailServer |
ClientId |
Azure AD app registration client ID | (required) |
MailServer |
ClientSecret |
Azure AD app registration client secret | (required) |
MailServer |
From |
Mailbox address mail is sent from | (required) |
MailServer |
ForceRemoveOnFailure |
Remove emails from the queue even if they fail to send | false |
If you want to build from source instead of using a released artifact:
- Install the .NET SDK version matching the one used by the release workflow (currently
10.0.x). - Restore and build the solution:
dotnet restore dotnet build --configuration Release
- Publish the service. On Windows this produces a Windows Service host; on Linux it produces a systemd-compatible daemon:
dotnet publish MantisBTMailTask/MantisBTMailTask.csproj --configuration Release --output publish
- Copy the contents of the
publishfolder, along withmantisbtmailtask.serviceon Linux, to the location you want to run the service from, then continue from step 4 of Installation.
This project is licensed under the MIT License.