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


williamwlkAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zazagorCommented:
Hi,

The solution is to simply move/delete the queue-files.
In the mail spooler folder:
mailq |grep -v 'domain1.mail.us' | awk -F: '{print $1}' | awk -Ff '{print $2}' | xargs -I file rm -f dffile qffile
(instead of deleting with rm, you could move with mv)

I usually delete mail from mail queue that has no sender address:
mailq | grep '<>' | awk '{print $1}' | xargs -I file rm -f qffile dffile

//zaZagor
0
Pieter JordaanSenior Systems Administrator - Web hosting and Network Security.Commented:
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.
0
expert1010Commented:
1. This would do
Run this to see if it catches the mail.
mailq | tail +2 | grep -v '^ *(' | awk  'BEGIN { RS = "" } { if ($8 ~ /^[a-z]+@domain1.mail.us/ && $9 == "") print $1 }' | tr -d '*!'

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

2. -h with postsuper does the trick. You can then investigate the mails after that. They are in the hold queue and will not be handled further without your explicit intervention. raw access to the files are in your postfix path in main.cf. "grep queue_directory /etc/postfix/main.cf"

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

3. If you're having trouble sending to much mail to destinations you could use postfixes bulit in limiting system.  This I belive you have to experiment with. Have a look at this.
http://www.postfix.org/TUNING_README.html#hammer
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

williamwlkAuthor Commented:
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

0
williamwlkAuthor Commented:
?
0
williamwlkAuthor Commented:
It is a direct hit answer! Thank you, Guys!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Networking

From novice to tech pro — start learning today.