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 0Reference
https://www.linuxbabe.com/mail-server/setup-basic-postfix-mail-sever-ubuntu
https://www.linuxfordevices.com/tutorials/ubuntu/smtp-relay-on-ubuntu
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-22-04
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-mail_servers#s2-email-mta-postfix
Last updated