Postfix

Configuration

Using Postconf

  • postconf -n [name]: Show only configuration parameters that have explicit name=value settings in main.cf

  • postconf -d [name]: view default value

  • postconf -e "name=value"

  • postfix reload: reload configuration after changing

Verification

  • send test email: echo "This is the body of the email" | mail -s "This is the subject line" recipient_email_address

  • tail /var/log/maillog: view mail log

  • cat /var/mail/$account: view mail to account

Postmap

#!/bin/bash
###
## sh /sx_sys/postfix_mynetwork_ip_checker.sh
LOGFILE="/var/log/smtp_relay.log"

curent_ip=$(dig @exemple.com exemple.com | awk '/^;; ANSWER SECTION:$/ { getline ; print $5 }')
#echo $curent_ip

saved_ip=$(</etc/postfix/network_table )
#echo $saved_ip
if [ "$curent_ip OK" != "$saved_ip" && -n "$curent_ip"]; then
echo "$curent_ip OK" > "/etc/postfix/network_table"
postmap /etc/postfix/network_table
echo "$(date) smtp allow for $curent_ip" >> $LOGFILE 2>&1
mail -s "smtp allow for $curent_ip $(date)" [email protected] < /dev/null
fi
exit 0

Reference

Last updated