Exim / Postfix / dovecot tidbits

home | blog | Teh Internet | guest blog |rants | placeholder | political | projects | Gwen and Liam | Citadel patched | Tools | Scouts

- Careful Chrome users, this search box might be "Not secure"

blow out the spool - if the other main process is not running any longer, good for when you are pushing some mail from a secondary mx that should not have ended up there in the first place, or when moving servers (don't forget to make exim only listen on loopback)

exim -bd -qff 15m

Dangerous way to grep for mail from a user (better to use exiqgrep)

cd /var/spool/exim/input
grep user@example.com *H | cut -c 1-16 | xargs exim -Mrm
Or using the mailq command:
mailq | grep "<user@domain>" | cut -c 11-27 | xargs exim -Mrm

Horrible hack for long lists of args (warning - this deletes them from the queue):
find . -type f -print0 | xargs -0 grep "user@example.com" | cut -c 3-18 | xargs exim4 -Mrm

Ignore all this below, just see this site for postfix stuff - much better than any reading of the man pages:
I love the mixture of Sendmail knowledge required to guess at what to do in Postfix!
 - same horrible hack for postfix (warning - this deletes all from the queue for domain):
mailq | grep somedomain.com | cut -d" " -f1
 - clean out with:
mailq | grep somedomain.com | cut -d" " -f1 | postsuper -d -
- check postfix mail queue messages with:
postcat -vbeh `find .` (needs a list of ID's from /var/spool/postfix/deferred).
 - Better one off:
 mailq (or postqueue -p) - this gives the message id's
 postcat -vq XXXXXXX (message id from mailq / postqueue command).

Horrible hack to force deliver them:
find . -type f -print0 | xargs -0 grep "domain.whatever" |  cut -c 3-18 | sort | uniq | xargs exim -M

good exim cheat sheet!

Stolen from above (and mixed and matched bits from above):

(fetch message numbers from doman x)
 exiqgrep -ir domain.com > domain
(force delivery of domain x mail)
 exim -M `cat domain`

To view the message from the postfix queue (knowing the id):

postcat -vq XXXXXXXXXX

to delete

postsuper -d XXXXXXXXXX 

The same (view header and body in Exim):

exim -Mvh message-id    <- view header
exim -Mvb message-id    <- view body

To find the Exim config:
exim -bV

To show the Exim running config:
exim -bP

Dovecot - show the namespace config:
dovecot -n

For the kitchen sink:
dovecot -a

Re-write header info, and re-submit message to postfix!
Nice summary from here: https://serverfault.com/questions/623211/postfix-change-sender-in-queued-messages
Thanks masegaloeh! https://serverfault.com/users/218590/masegaloeh
And, as always, the pertinent bits here, in case my blog outlives the referenced source:
# postsuper -h queueid
# postcat -qbh queueid > tempfile.eml
# vi tempfile.eml
Resubmit queue and delete old queue

# sendmail -f $sender $recipient < tempfile.eml
# postsuper -d queueid