Postfix Notification Management Guide#

This guide breaks down the process into manual steps. Each block contains specific commands to audit, remove, or verify your mail configuration.


1. Part 1: Test if Configuration is Present#

These commands verify if the Gmail relay and header rewriting are currently active on the server.

1.1. Check Service and Dependencies#

Verify if Postfix is active and if the relay-specific modules are installed.

systemctl is-active postfix
dpkg -l | grep -E 'libsasl2-modules|mailutils|postfix-pcre'

1.2. Locate Credential and Mapping Files#

Check for the existence of the SASL password database and the header check configuration.

ls -l /etc/postfix/sasl_passwd
ls -l /etc/postfix/sasl_passwd.db
ls -l /etc/postfix/smtp_header_checks

1.3. Inspect Relay Settings#

Search the main configuration file for the Gmail relayhost and SASL authentication settings.

grep -E 'relayhost|smtp_sasl|smtp_header_checks' /etc/postfix/main.cf

2. Part 2: Removal of Configurations#

Follow these steps in order to decommission the relay and reset the system to local-only mail.

2.1. Stop Postfix Service#

Stop the service to prevent any stuck mail in the queue from attempting to send during cleanup.

systemctl stop postfix

2.2. Delete Configuration and Secret Files#

Remove all files created during the initial setup, including the sensitive password database.

rm -v /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
rm -v /etc/postfix/smtp_header_checks /etc/postfix/smtp_header_checks.db

2.3. Reset Main Configuration#

Overwrite the current configuration with a clean, local-only template. This removes all Gmail-specific directives.

cat <<EOF > /etc/postfix/main.cf
# Postfix configuration - Reset to Local Only
myhostname = $(hostname).proxmox
smtpd_banner = \$myhostname ESMTP \$mail_name (Debian/GNU)
biff = no
append_dot_mydomain = no
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = \$myhostname, localhost, localhost.localdomain
relayhost =
mynetworks = 127.0.0.0/8
inet_interfaces = loopback-only
recipient_delimiter = +
compatibility_level = 2
EOF

2.4. Purge Packages and Reload#

Remove the SASL modules and PCRE support, then restart the service.

apt purge -y libsasl2-modules mailutils postfix-pcre
apt autoremove -y
systemctl enable postfix
systemctl start postfix
postfix reload

3. Part 3: Test if Removed OK#

Verify that the system no longer contains traces of the external relay.

3.1. Verify File Absence#

Ensure the credential and mapping files have been physically deleted.

ls /etc/postfix/sasl_passwd
ls /etc/postfix/smtp_header_checks

3.2. Verify Configuration Reset#

Ensure the relayhost is empty and no SASL settings remain in the active config.

grep "relayhost" /etc/postfix/main.cf
grep "sasl" /etc/postfix/main.cf

3.3. Final Log Audit#

Check the mail log to confirm no background processes are still attempting to reach Google’s SMTP servers.

tail -n 20 /var/log/mail.log