' mailq ' often returns various problem mails : such mails would hog genuine
mails from going thru
I need to search for a list of text / string that's found from "mailq" output
& then the script would return the first value of the line just preceding the
line these text were found.
List of search text / string are (which may be added in future ):
a) "Connection timed out"
b) "lowest numbered MX record"
c) "Connection refused"
d) "Mailbox size limit exceeded"
e) "Undeliverable address"
f) "Network is unreachable"
g) "exceed mailbox quota"
..... this list of search text may grow .....
& based on the sample mailq output below, the script would return the values
DD063290F38
D8E42291DBE
D440F291197
D3E14291D93
. . .
These values are the problem mails' ids & will be passed to postsuper to
be withheld in 'hold' queue :
mailq | script_needed | postsuper -h -
Sample problems mails returned by mailq :
. . . . . .
DD063290F38 2924 Tue Mar 1 10:17:13 sssspc@xx.sg
(host mail.phins.com.sg[119.73.200.204] said: 452 <jason@phins.com.sg> Mailbox size limit exceeded (in reply to RCPT TO command))
jason@phins.com.sg
D8E42291DBE 2919 Tue Mar 1 10:20:43 sssspc@xx.sg
(connect to ritzmail.RITZ-CARLTON.COM.SG[203.120.129.130]: Connection timed out)
JOSEPHINE@RITZ-CARLTON.COM.SG
D440F291197 2185 Fri Feb 25 15:15:24 sssspc@xx.sg
(Host or domain name not found. Name service error for name=GMAIL.COM.SG type=MX: Host not found, try again)
DR.JOSEPH.ANG@GMAIL.COM.SG
D3E14291D93 3051 Tue Mar 1 10:19:51 sssspc@xx.sg
(host mailserv.skylightgroup.com[202.52.100.7] said: 452 Message for <florenceteh@melandas.com.sg> would exceed mailbox quota (in reply to RCPT TO command))
florencet@meland.com.sg
9B90CA58AE 1278 Sun Feb 27 15:28:08 contact_autoreply@xx.sg
(connect to park.goldenname.com[75.125.148.76]: Connection refused)
Manue@3nan.com
E7EEBA579E 1272 Sun Feb 27 19:48:56 contact_autoreply@xx.sg
(host alt1.aspmx.l.google.com[74.125.65.27] said: 450-4.2.1 The user you are trying to contact is receiving mail at a rate that 450-4.2.1 prevents additional messages from being delivered. Please resend your 450-4.2.1 message at a later time. If the user is able to receive
pattern_file should just contain the search strings, without surrounding qotes:
Connection timed out
lowest numbered MX record
Connection refused
Mailbox size limit exceeded
Undeliverable address
exceed mailbox quota
wmp