Notifications

Overview

Email notifications are event-driven, triggered by audit events recorded in the sftp_audit database table. This means JDBC audit must be enabled for notifications to function — the notification engine reads directly from the audit table to determine which events require alerting.

Three rule types cover different alerting patterns: simple (one email per event), threshold (fires after N events in a time window), and batch (accumulates events per user, sends a digest).

SMTP Configuration

Add a <notifications> block to conf/sftp-server.xml with the SMTP server details and one or more notification rules:

<notifications>
    <smtp>
        <host>mail.example.com</host>
        <port>587</port>
        <starttls>true</starttls>
        <username>alerts@example.com</username>
        <password>appPassword</password>
        <from>noreply@example.com</from>
    </smtp>
    <rules>
        <!-- rules here -->
    </rules>
</notifications>
Element Description
<host> SMTP server hostname or IP address.
<port> SMTP port. Common values: 25 (plain), 465 (implicit TLS), 587 (STARTTLS).
<starttls> Enable STARTTLS upgrade on the connection. Set to true for port 587.
<username> SMTP authentication username. Omit if the server does not require authentication.
<password> SMTP authentication password or application-specific password.
<from> Sender address used in the From header of outgoing emails.

Testing SMTP Connectivity

Use the admin CLI to verify that the SMTP configuration is correct before deploying notification rules:

admin test-email --to admin@example.com

This sends a test message using the configured SMTP settings. If delivery fails, the error message will indicate the cause (connection refused, authentication failure, TLS handshake error, etc.).

Rule Types

All rules are defined inside the <rules> element. Each <rule> specifies an event type and a recipient address. The rule type is determined by which additional attributes are present.

1. Simple Rule

Sends one email immediately for each matching event. Use this for critical events that require instant notification.

<rule event="UPLOAD_COMPLETE" to="ops@example.com" />

In this example, every completed upload triggers an email to the operations team.

2. Threshold Rule

Fires after a specified number of matching events occur within a time window. Use this for anomaly detection — situations where a single event is normal but a burst indicates a problem.

<rule event="AUTH_FAILURE" to="sec@example.com" threshold="5" window="PT5M" />

In this example, the security team is alerted when 5 authentication failures occur within 5 minutes. The window attribute uses ISO 8601 duration format (e.g. PT5M = 5 minutes, PT1H = 1 hour).

3. Batch Rule

Accumulates events per username and sends a single digest email after a configurable window. Use this to avoid email storms from high-volume operations like bulk file transfers.

<rule event="UPLOAD_COMPLETE" to="ops@example.com" batch-window="PT30S" />

In this example, uploads are grouped by username. After 30 seconds of inactivity (no new uploads from that user), one email is sent containing a CSV manifest of all uploads in the batch. The batch-window attribute uses ISO 8601 duration format.

Supported Events for Rules

The following audit event types can be used in notification rules:

Event Type Description
UPLOAD_COMPLETE A file upload finished successfully and was renamed to its final name.
UPLOAD_ABORTED A file upload was interrupted or abandoned before completion.
AUTH_FAILURE An authentication attempt failed (wrong password or key).
AUTH_ACCOUNT_LOCKED An authentication attempt was rejected because the account is locked.
AUTH_SUCCESS A user authenticated successfully.
DOWNLOAD_COMPLETE A file download finished successfully.
SESSION_CONNECT A new SFTP session was established.
SESSION_CLOSED An SFTP session was terminated.

Email Format

Each notification email contains two parts:

CSV Columns

Column Description
EventType The audit event type (e.g. UPLOAD_COMPLETE).
Timestamp ISO 8601 timestamp of the event.
Username The SFTP account that triggered the event.
RemoteIP Client IP address.
Filename The file involved (if applicable).
Size File size in bytes (if applicable).
Detail Additional context (error message, reason, etc.).

For batch emails, the CSV contains multiple rows — one per event in the batch, grouped by username. The CSV attachment filename follows the pattern:

{event-type}-{username}-{timestamp}.csv

For example: UPLOAD_COMPLETE-alice-20260317T143022.csv

Architecture

Understanding the notification pipeline helps with troubleshooting and performance tuning.

Processing Pipeline

SmtpNotificationSink is part of the CompoundAuditSink chain. When an audit event arrives, the sink signals the notification thread but performs no database work in the event path itself. The notification thread then:

  1. Waits 500 milliseconds after the signal to allow JdbcAuditSink to flush its asynchronous batch to the database.
  2. Queries the sftp_audit table for unprocessed rows using a LEFT JOIN against sftp_notification_log.
  3. Evaluates each unprocessed event against the configured rules.
  4. Sends emails for any rules that match.
  5. Records sent notifications in sftp_notification_log to prevent duplicate delivery.

Reliability Features

Dependencies

Email delivery uses Eclipse Angus Mail 2.0.3, the reference implementation of the Jakarta Mail API. This library is licensed under EPL-2.0 with a GPLv2 Classpath Exception, which permits linking without GPL obligations.

User Email Addresses

Each SFTP user and admin user can have an email address associated with their account. Emails are stored in separate tables (sftp_user_emails and sftp_admin_emails) and can be managed from all admin surfaces:

Admin email addresses are used as recipients for critical server alerts.

Critical Server Alerts

The admin alert system sends email notifications to all admin users (who have an email address configured) when critical server events occur. Unlike rule-based notifications, alerts are triggered directly by server components and do not require the JDBC audit sink.

Configuration

Add an <admin-alerts> block inside <notifications> in conf/sftp-server.xml:

<notifications>
    <smtp>
        <!-- SMTP config (required) -->
    </smtp>
    <admin-alerts enabled="true">
        <events>DISK_LOW,DISK_CRITICAL,CERT_EXPIRING,LICENSE_EXPIRING</events>
    </admin-alerts>
</notifications>
Element Description
enabled Master switch for admin alerts (true / false).
events Comma-separated list of alert types to enable. Leave empty for all.

Alert Types

Alert Type Trigger Source
DISK_LOW Available space on a monitored volume has fallen below the threshold. VolumeGuard (on upload rejection)
DISK_CRITICAL Available space is below 25% of the configured threshold. VolumeGuard (on upload rejection)
DB_UNREACHABLE The audit database is not responding to health checks. Hourly health check
CERT_EXPIRING An SSL/TLS certificate will expire within 30 days. Hourly certificate scan
LICENSE_EXPIRING The activation key has 30 or fewer days remaining. Hourly subscription enforcer
BRUTE_FORCE An IP address has been auto-blacklisted for excessive connections. Connection rate limiter
SERVER_STARTED The SFTP server has started and all listeners are ready. Server startup
SERVER_STOPPED The SFTP server is shutting down. Server shutdown

Behaviour