Aside from the lazy 'grep administrator.com' bit. . . yeah.
I often do some variation on (as root in a script):
smtpctl show queue | awk -F\| '$3 == "mta" && $5 == "@" {print $1}' | xargs -n1 smtpctl remove
to remove unbouncable junk. This is much more flexible than adding a bunch of options to 'remove' to remove some regex/match/DSL thingie.
Sean
PS You can use regex matching instead of '==' in my sample line.
> On Dec 22, 2021, at 05:25, kasak <kasak@kasakoff.net> wrote:
>
> Hello misc! How do you clean messages for one mailbox?
>
> for example, i have this in my queue:
>
> 2cce379a666925bc|local|mta|auth|@|info@administrator.com|info@administrator.com|1640178598|1640178598|1640178598|0|inflight|24|
> 3c712effebd6fe5a|local|mta|auth|@|bounce-860-17875544-860-248@yplinyi02.cn|bounce-860-17875544-860-248@yplinyi02.cn|1640140496|1640140496|0|10|pending|1874|Network error on destination MXs
> 90f946248731d1d9|local|mta|auth|@|info@administrator.com|info@administrator.com|1640178200|1640178200|1640178600|1|inflight|22|Network error on destination MXs
> 98eb22222ef2094f|local|mta|auth|@|info@administrator.com|info@administrator.com|1640177337|1640177337|0|2|pending|315|Network error on destination MXs
>
> now i want to remove all messages from @administrator.com.
>
> this is how it can be done:
>
> ----------
>
> for i in `doas smtpctl show queue | grep administrator.com | awk -F "|" '{print $1}'`
>
> doas smtpctl remove $i
>
> ----------
>
> It works, but the whole concept is just scary! Usually i try to avoid such bulky constructions.
>
> Maybe I missed something, and it can be made easier ?
No comments:
Post a Comment