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?
 
expert1010Connect With a Mentor Commented:
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
 
zazagorConnect With a Mentor Commented:
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.