Skip to content

Set up email and SMTP notifications

Use your own SMTP server for cPFence v4+ on Enhance alerts, or keep the server’s local mail delivery. You need View System Settings and Manage Notification Settings; terminal setup needs root on the intended server.

  1. Open System Settings, choose one Server scope, and select Notification Settings.
  2. Enter Notification email and select the events you want to receive.
  3. Under Delivery connections, choose cPFence SMTP → Set new configuration.
  4. Enter SMTP host, Port, SMTP username, SMTP password, and From email. The form starts with 587; use the port and sender authorized by your provider.
  5. Select Save changes and read the result. Configuration sends a test email; check the inbox and spam folder, and verify the sender.

cPFence SMTP Set new configuration form with blank SMTP host, username, password and From email fields, and Port set to 587.

Enter provider-authorized connection details privately. This blank setup form has not been saved or tested. Select the image to enlarge it; use your browser's Back command to return.

Notification Settings showing notification email and event switches.

Notification email and event switches. Secrets and identifying details are hidden. Select the image to enlarge it. Use your browser’s Back command to return.

For several servers, stage the SMTP fields and use Apply to servers…. Review destinations and Changed fields, then check each result. Selecting All Servers in the sidebar alone does not copy SMTP settings.

On the intended server, start interactive notification SMTP setup:

Terminal window
cpfence --enable-cpfence-smtp

Confirm the recipient and enter the provider’s host, port, credentials, and sender. Enter the port explicitly; a blank terminal port defaults to 25. Setup sends a test message.

To test delivery and change the notification recipient, replace this example address with yours:

Terminal window
cpfence --set-email [email protected]

This saves the address after a successful send. Saving the WebUI recipient alone does not send a test.

For a manual test without changing the recipient setting, replace the address below and run:

Terminal window
mailx -v -s 'SMTP Test Email from cPFence' '[email protected]' <<< 'This is a test email to confirm the SMTP configuration for cPFence notifications.'

This sends a real message using the configured mail sender. Check the result and receipt separately.

To return to local mail delivery, choose Disable cPFence SMTP and save, or run cpfence --disable-cpfence-smtp and confirm. Keep current configuration preserves the saved sender.

3. Choose notification SMTP or global SMTP

Section titled “3. Choose notification SMTP or global SMTP”
Choice Effect
cPFence SMTP Configures the cPFence sender in /etc/s-nail.rc. Website and mailbox mail are not redirected.
Global SMTP Configures a server-wide Postfix relay and the cPFence sender. Website and mailbox mail can use the relay too.

On that server, run:

Terminal window
cpfence --enable-global-smtp

Enter the private SMTP details, specifying the port. Read the Postfix and existing-relay confirmations. Declining Postfix setup configures only the notification sender. Accepting setup sends a test; verify both notifications and normal outgoing mail.

Setup owns its marked blocks and /etc/postfix/cpfcli_sasl_passwd files, preserving unrelated text. cpfence --disable-global-smtp removes the owned relay and notification sender after confirmation, then applies the Postfix change. Disabling cPFence SMTP in the WebUI leaves a global relay in place.

  1. Check the recipient, event switch, and owning module’s state.
  2. Review the setup error and provider’s host, port, authentication, and sender requirements.
  3. Check spam filtering and provider delivery logs. For local mail, inspect existing mail logs, such as /var/log/mail.log, or the Postfix journal.
  4. Ask the mail administrator to check routing, DNS, and SPF/DKIM/DMARC if messages are rejected or marked as spam.

Use Slack notifications if you prefer alerts in a channel. Review notification event settings separately.