Postfix

Some useful links to explain the concepts of Postfix

Concepts

Configuration

SSL/TLS on Postfix

Troubleshooting & Log Parsing

Queue Management

Commands

  • Sorting queued mails by From address

1sudo mailq | awk '/^[0-9,A-F]/ {print $7}' | sort | uniq -c | sort -n
  • Holding queued mails by From address

1sudo mailq| grep '^[A-Z0-9]'| grep <sender-ID>| cut -f1 -d' ' | tr -d \*|sudo postsuper -h -
  • Holding queued mails by To address

1sudo mailq | tail -n +2 | grep -v '^ *(' | awk  'BEGIN { RS = "" } { if ($8 == "<recipient>") print $1 } ' | tr -d '*!' | sudo postsuper -h -
  • Holding queued mails by Domain

1sudo mailq| grep '^[A-Z0-9]'| grep @<domain>| cut -f1 -d' ' | tr -d \*|sudo postsuper -h -
  • Holding emails from the [active|deferred] queue based on subject

1sudo find /var/spool/postfix/[active|deferred]/ -type f  -exec grep -il '<subject>' '{}' \; | xargs -n1 basename | sudo postsuper -h -
  • Removing Mails based on sender Address

1sudo mailq| grep '^[A-Z0-9]'| grep <sender-ID>| cut -f1 -d' ' | tr -d \*|sudo postsuper -d -
  • Removing Mails based on Domain

1sudo mailq| grep '^[A-Z0-9]'| grep @<domain>| cut -f1 -d' ' | tr -d \*|sudo postsuper -d -
  • Delete mails to a specific mail address

1sudo mailq | tail -n +2 | grep -v '^ *(' | awk  'BEGIN { RS = "" } { if ($8 == "<recipient-ID>") print $1 } ' | tr -d '*!' | sudo postsuper -h -