{"id":1199,"date":"2015-09-21T13:28:55","date_gmt":"2015-09-21T18:28:55","guid":{"rendered":"http:\/\/osric.com\/chris\/accidental-developer\/?p=1199"},"modified":"2015-09-21T13:29:56","modified_gmt":"2015-09-21T18:29:56","slug":"holding-messages-in-the-postfix-mail-queue","status":"publish","type":"post","link":"https:\/\/osric.com\/chris\/accidental-developer\/2015\/09\/holding-messages-in-the-postfix-mail-queue\/","title":{"rendered":"Holding messages in the Postfix mail queue"},"content":{"rendered":"<p>Earlier today, someone sent a large number of email messages each containing a 30 megabyte attachment to users on our servers. This put our Postfix servers under a heavy load and caused some messages to be delivered after a substantial delay. (This was in part due to additional processing done by our servers, I&#8217;m sure a plain-jane Postfix instance could have handled it without an issue.) <\/p>\n<p>This was no good. The sender&#8211;let&#8217;s call it bigbulk.test.com&#8211;should be able to send such messages, but not at the expense of normal mail delivery. I needed to change the priority of those messages to let other messages take priority.<\/p>\n<p>The first thing I did was to hold all the mail from bigbulk.test.com:<\/p>\n<ul>\n<li>Retrieve the mail queue<\/li>\n<li>Select only the lines containing bigbulk.test.com<\/li>\n<li>Select only the queue ID, the first item listed in each result<\/li>\n<li>Pass the queue IDs to the postsuper -h command<\/li>\n<\/ul>\n<p><code>mailq | grep bigbulk.test.com | cut -d ' ' -f 1 | xargs -n1 postsuper -h<\/code><\/p>\n<p>But what about delivering them? I sent them in small batches so as not to overload the server again.<\/p>\n<ul>\n<li>Retrieve the mail queue<\/li>\n<li>Select only the lines containing bigbulk.test.com<\/li>\n<li>Select only the queue ID (stripping out the hold-indicator)<\/li>\n<li>Select only the first 5 results<\/li>\n<li>Pass the queue IDs to the postsuper -H command<\/li>\n<\/ul>\n<p><code>mailq | grep bigbulk.test.com | cut -d '!' -f 1 | head -n5 | xargs -n1 postsuper -H<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Earlier today, someone sent a large number of email messages each containing a 30 megabyte attachment to users on our servers. This put our Postfix servers under a heavy load and caused some messages to be delivered after a substantial delay. (This was in part due to additional processing done by our servers, I&#8217;m sure &hellip; <a href=\"https:\/\/osric.com\/chris\/accidental-developer\/2015\/09\/holding-messages-in-the-postfix-mail-queue\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Holding messages in the Postfix mail queue<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[232],"tags":[197,362],"class_list":["post-1199","post","type-post","status-publish","format-standard","hentry","category-tips-tricks","tag-bash","tag-postfix"],"_links":{"self":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/comments?post=1199"}],"version-history":[{"count":6,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1199\/revisions"}],"predecessor-version":[{"id":1217,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/1199\/revisions\/1217"}],"wp:attachment":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/media?parent=1199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/categories?post=1199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/tags?post=1199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}