Systemd
This document explains how to install and manage RustMailer as a systemd service on Linux systems.
Precompiled binaries are automatically available in each GitHub Release.
📦 Installation
Step 1: Download the Binary
# Create installation directory
sudo mkdir -p /opt/rustmailer/bin
sudo chown -R $USER:$USER /opt/rustmailer
# Download latest release (replace X.Y.Z with actual version)
RELEASE="X.Y.Z"
wget https://github.com/rustmailer/rustmailer-core/releases/download/${RELEASE}/rustmailer -O /opt/rustmailer/bin/rustmailer
# Make executable
chmod +x /opt/rustmailer/bin/rustmailer
Step 2: Create Data Directory
# Replace </your/data/path> with your actual directory
sudo mkdir </your/data/path>
sudo chown -R $USER:$USER </your/data/path>
🛠️ Systemd Service Setup
Create the service file at /etc/systemd/system/rustmailer.service
:
[Unit]
Description=RustMailer Email Service
After=network.target
Documentation=https://github.com/rustmailer/rustmailer-core
[Service]
Type=simple
User=rustmailer
Group=rustmailer
WorkingDirectory=/opt/rustmailer
# Environment file (create this at /etc/rustmailer.env)
EnvironmentFile=/etc/rustmailer.env
# Main executable
ExecStart=/opt/rustmailer/bin/rustmailer
# Standard output/error logging
StandardOutput=journal
StandardError=journal
# Security hardening
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
RestrictSUIDSGID=true
# Auto-restart
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
Create Dedicated User
sudo useradd --system --home-dir /opt/rustmailer --shell /usr/sbin/nologin rustmailer
# Replace </your/data/path> with your actual directory
sudo chown -R rustmailer:rustmailer /opt/rustmailer </your/data/path>
Example Environment File
Create /etc/rustmailer.env
with your configuration:
# Replace </your/data/path> with your actual directory
RUSTMAILER_ROOT_DIR=</your/data/path>
RUSTMAILER_HTTP_PORT=15630
RUSTMAILER_GRPC_ENABLED=true
RUSTMAILER_GRPC_PORT=16630
RUSTMAILER_BIND_IP="0.0.0.0"
RUSTMAILER_PUBLIC_URL="http://your-server:15630"
RUSTMAILER_LOG_TO_FILE=true
🚀 Managing the Service
# Reload systemd after configuration changes
sudo systemctl daemon-reload
# Start the service
sudo systemctl start rustmailer
# Enable auto-start on boot
sudo systemctl enable rustmailer
# Check status
sudo systemctl status rustmailer
# View logs
sudo journalctl -u rustmailer -f
🔄 Updating RustMailer
# Stop service
sudo systemctl stop rustmailer
# Download new binary (replace version)
wget https://github.com/rustmailer/rustmailer-core/releases/download/NEW.VERSION/rustmailer -O /opt/rustmailer/bin/rustmailer
chmod +x /opt/rustmailer/bin/rustmailer
# Start updated service
sudo systemctl start rustmailer
🔍 Health Monitoring
The service includes built-in health checks:
# HTTP health endpoint (if enabled)
curl http://localhost:15630/api/status
# Systemd integrated checks
systemctl is-active rustmailer
🧩 Additional Notes
- The service runs under dedicated
rustmailer
user for security - Logs are available at:
</your/data/path>/logs/rustmailer.log
- Configuration is managed through
/etc/rustmailer.env
- Consider setting up log rotation if using file logging
✅ Example Deployment
- Install binary to
/opt/rustmailer/bin
- Create
/etc/rustmailer.env
with your configuration - Enable the service:
sudo systemctl enable --now rustmailer