Link to home
Create AccountLog in
Avatar of williamwlk
williamwlk

asked on

Postfix mailq management question

Dear Senior Mail Admins,

I would like to seek your advise on mailq management:

-----------------
root@09:30:04@mailserver:~# mailq | grep "421 too many connections" | grep "(delivery temporarily suspended" |  cut -d " " -f 5 | sort | uniq -c | sort -rn
   5658 domain1.mail.us[64.xxx.xx.xxx]
   4988 mail-server.ourdomain.edu[70.xxx.xxx.xxx]
   375 mail.domainxxx.edu[64.xxx.xxx.xxx]
    192 mail.ourworldxxx.com[66.xxx.xxx.xxx]
-----------------

mailq | grep "421 too many connections"
(delivery temporarily suspended: host domain1.mail.us[64.xxx.xx.xxx] refused to talk to me: 421 too many connections)
(delivery temporarily suspended: host mail-server.ourdomain.edu[70.xxx.xxx.xxx] refused to talk to me: 421 too many connections)

-------------------

Let's say, I have a scenario: where my mailq is blown up coz of this!


I'd like to do two things:


1. I would like to delete all the mails in the mailq destined for those domains.
2. How can I temporarily move all those mails in the mailq destined for those domains to a temp folder?
3. What else can we do about it?


Thank you for your valuable piece of advise in advance.

William


SOLUTION
Avatar of zazagor
zazagor
Flag of Sweden image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Hi

Are those legitimate emails?
There are many mail server spam tools that will relay mail if your server is not properly protected.

Spamassassin and postgrey work really well together to reduce spam on postfix.
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of williamwlk
williamwlk

ASKER

Thank you all for your support. Sorry for my late response as I was tied up to my operation.

expert1010: I have one issue:

mailq | tail +2 | grep -v '^ *(' | awk  'BEGIN { RS = "" } { if ($8 ~ /^[a-z]+@domain1.mail.us/ && $9 == "") print $1 }' | tr -d '*!'

----> /^[a-z]+@gmail.com/ does catch mails like "william@gmail.com" coz it has single word but does not catch mails like "william.wlk@gmail.com" or "william_wlk@gmail.com" or "william.wlk.ace@gmail.com", which has two words or more joined with a dot or a dash.

Therefore, I'd like to change it to /.+@gmail.com/
which catches starting with any single character and can be followed by any one or more characters.

Any side effect you foresee or any issues you'd like to raise if I change so?

Thanks and regards,
William

?
It is a direct hit answer! Thank you, Guys!