SMTP/Postfix

Postfix
What is Postfix? An easy, fast, and secure SMTP server. Did I mention it was easy to configure?
Major Postfix specific configurations
  • main.cf    => Specifies a very small subset of all the parameters that control the operation of Postfix. Parameters not explicitly specified are left at their default values. 
  • master.cf => Defines how a client program connects to a service, and what daemon program runs when a service is requested.


To setup postfix need below rpm:

yum install postfix 
yum remove sendmail


The server acting as a mail transfer agent uses TCP port 123


Common Commands 

service postfix reload    => reload postfix configuration and hash tables
service postfix [restart, stop, start]    => stop/starts/restarts Postfix
mailq    => view the active mail queue (you can alternative run postqueue -p)
postcat -q <QID>    => View email that's in queue 
postqueue -f    => Reprocess messages in Queue and immediately retry delivery
postmap /etc/postfix/access    => Reload sender access list
postmap /etc/postfix/transport    => Reload Transport table


To kill one email

postsuper -d 56F7F20515


Save and close the file. Restart / reload postfix MTA:

# /etc/init.d/postfix restart

To concurrently watch emails:

watch -n1 mailq


To delete all email in the queue from a domain run this command as root:

postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } /@example\.com/ { print $1 }' | tr -d '*!' | postsuper -d -


To delete all email in the queue From: a specific email address run this command as root:

postqueue -p | tail -n +2 | awk 'BEGIN { RS = "" } /username@example\.com/ { print $1 }' | tr -d '*!' | postsuper -d -


TLS issue:


Add below to /etc/postfix/main.cf :
CASE 1 (Send TLS encrypted emails if supported else send without TLS):

smtp_tls_security_level=may
smtp_tls_loglevel=1

Comment below line:

smtp_tls_policy_maps = hash:/etc/postfix/tls_policy

Restart postfix: /etc/init.d/postfix reload
-----------------------------------------------------------------------------------
CASE 2 (Send encrypted emails only to google):
Update: /etc/postfix/tls_policy to contain below line:

 gmail.com         secure

Restart postfix: /etc/init.d/postfix reload


No comments:

Post a Comment