RE: Sort maildir and send smallest first
(Picking up a thread running from 26th July to 9th August) Jacob, I find that qmail is taking my maildir and sending last in first out I would like to have qmail changed to do a sort mailbox by seize and send the smallest first. I've not got round to replying to this one: There may be an easy solution for you as follows - I've noticed that the order of messages listed by qmail-pop3d can be altered by touching (Unix command "touch") the messages in the new/cur directories. I assume that within a (C) program you could do the same with open-for-append followed by close. To perform tricks with this for qmail-pop3d, you can write a small shim to go between checkpassword and qmail-pop3d which 'touches' [in your case] all small files in Maildir/new, Maildir/cur before exec-ing qmail-pop3d as normal. This even works if your varying size files are distributed across new and cur! I haven't looked at the qmail-pop3d code, but I assume this is down to 'Cool DJB code' rather than a quirk of the system I tried it on (Linux). Hopefully the same can be achieved in your case for other mail collection mechanisms. cheers, Andrew. PS: Where's ".lk"?
Re: Sort maildir and send smallest first
On Fri, Aug 18, 2000 at 11:22:01AM +, Andrew Richards wrote: I assume that within a (C) program you could do the same with open-for-append followed by close. No, you use utime(). To perform tricks with this for qmail-pop3d, you can write a small shim to go between checkpassword and qmail-pop3d which 'touches' [in your case] all small files in Maildir/new, Maildir/cur before exec-ing qmail-pop3d as normal. If you touch all the small files, then the big files will come earlier in the list! If you want to get all the small files first, you can do something like this: #!/usr/bin/perl -w if (opendir(CUR, ".")) { map { my @sb; utime($sb[8], $sb[7], $_) if (@sb = stat($_)); } readdir(CUR); closedir(CUR); } This sets the timestamp of all the files in the current directory to their sizes. This is clearly a hack, but would probably work. This even works if your varying size files are distributed across new and cur! I haven't looked at the qmail-pop3d code, but I assume this is down to 'Cool DJB code' rather than a quirk of the system I tried it on (Linux). Your message prompted me to have a look at the code. Indeed it's roughly sorted by the mtime of the messages. I say roughly because I did a pen- and-paper test of the prioq functions and saw that it's not always fully sorted. ---Chris K. -- Chris, the Young One |_ heartbleed (OpenBSD/i386) has now been up for Auckland, New Zealand |_ all of 14 days, 06:54:32 http://cloud9.hedgee.com/ |_
Re: Sort maildir and send smallest first
I recall from an earlier discussion of a similar problem that a perceived consensus was reached that a good way to do this kind of thing is to patch qmail-remote so that if the message is too big to send, it appears as a temporary error without even attempting to connect. also the definition of "too big to send" is read in from the file system in such a way that it can be easily monitored, and easily manipulated by a cron job. Something like the (non)existence of /var/mail/control/okay-to-send-big. After the status changes, an ALRM signal is generated to reprocess all backed up mail (most of which is there due to being oversize, it is hoped) and that is that. I do not know if this approach can be applied to maildirsmtp and serialmail. Peter van Dijk wrote: On Wed, Jul 26, 2000 at 08:45:34AM +0600, [EMAIL PROTECTED] wrote: [snip] I would like to have qmail changed to do a sort mailbox by seize and send the smallest first. ... The larger messages could then go at night where the x minutes is set to a higher value. -- David Nicol 816.235.1187 [EMAIL PROTECTED] Originator of the world's first combination bassinet and table saw
Re: Sort maildir and send smallest first
On Tue, Aug 08, 2000 at 05:05:21PM +, David L. Nicol wrote: I recall from an earlier discussion of a similar problem that a perceived consensus was reached that a good way to do this kind of thing is to patch qmail-remote so that if the message is too big to send, it appears as a temporary error without even attempting to connect. also the definition of "too big to send" is read in from the file system in such a way that it can be easily monitored, and easily manipulated by a cron job. Something like the (non)existence of /var/mail/control/okay-to-send-big. After the status changes, an ALRM signal is generated to reprocess all backed up mail (most of which is there due to being oversize, it is hoped) and that is that. Thanks. Sounds interesting. If anyone of you remember what to seach for then I shall search the archives. Perhaps I could search the body of text for qmail-remote ? Jacob
Re: Sort maildir and send smallest first
On Wed, Aug 09, 2000 at 07:02:19AM +0600, [EMAIL PROTECTED] wrote: On Tue, Aug 08, 2000 at 05:05:21PM +, David L. Nicol wrote: I recall from an earlier discussion of a similar problem that a perceived consensus was reached that a good way to do this kind snip Thanks. Sounds interesting. If anyone of you remember what to seach for then I shall search the archives. Perhaps I could search the body of text for qmail-remote ? Sorry for that one. That was not possible, I got far too many entries. I should have checked before sending. Any guess would be useful, I have almost all of last years mail on my server. Jacob
Re: Sort maildir and send smallest first
On Sun, Jul 30, 2000 at 08:26:59PM +0200, Peter van Dijk wrote: Hi Peter, a script to move the larger mail into a seperate IP and then login to that IP and get the bigger mail at night ? or have you something else in mind. When you run 'maildirsmtp', that in turn runs maildirserial which runs tcpclient which runs serialsmtp. Changing maildirsmtp's operation to, for example, handling bigger messages in a separate thread, would only require patching/replacing maildirserial to spawn two tcpclient+serialsmtp's instead of one. Filtering at delivery seems useless to me because that would mean you spread your mail over 2 Maildirs. Fortunately or unfortunately I am not able to generate a patch like that. If someone would like to help with a patch then I would like to test it out, but writing it, that I could not do. What I have done for the time being and it works me as a stop gap till further things are developed. Thanks for you tips, and please let me know what you come up with. Jacob Sri Lanka -- /etc/ppp/ip-up.local.small -- #!/bin/sh # this script is running during Day time # this will move large messages to the /var/qmail/alias/pppdir2 directory find /var/qmail/alias/pppdir/ -size +30 -exec mv {} /var/qmail/alias/pppdir2/new/ \; # This will send and recive mail the moment the ppp connection is up # To close the ppp connection when there is no more activity. # you put idle -25 in an option file called option.autoturn PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH maildirsmtp ~alias/pppdir alias-ppp- 203.115.29.130 metta.lk /etc/ppp/ip-up.local.large -- #!/bin/sh # this script is run at Night. # this will move large messages to the /var/qmail/alias/pppdir2 directory mv /var/qmail/alias/pppdir2/new/* /var/qmail/alias/pppdir/new # This will send and recive mail the moment the ppp connection is up PATH=/var/qmail/bin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin export PATH maildirsmtp ~alias/pppdir alias-ppp- 203.115.29.130 metta.lk -- /var/spool/cron/root -- 1 5 * * * cp -f /etc/ppp/ip-up.local.small /etc/ppp/ip-up.local 1 22 * * * cp -f /etc/ppp/ip-up.local.large /etc/ppp/ip-up.local I have done something similar on the incoming server side. My OS's are Redhat 6.0 -- A saying of the Buddha from http://metta.lk/ Having slain mother (craving) and father (conceit) and two warrior kings (views based on eternalism and nihilism), and having destroy a country (sense-avenues and sense-objects) together with its revenue officer (attachment), ungrieving goes the Brahmana (Arahant). Random Dhammapada Verse 294
Re: Sort maildir and send smallest first
On Sun, Jul 30, 2000 at 09:42:53PM +0600, [EMAIL PROTECTED] wrote: On Thu, Jul 27, 2000 at 06:19:00PM +0200, Peter van Dijk wrote: I have considered a similar change, having 2 maildirsmtp's running, one for mails under 32kbyte, one for bigger mails. That would do too. Looking at how maildirsmtp works, this shouldn't be that hard. Thanks for your reply, What do you suggest ? a script to move the larger mail into a seperate IP and then login to that IP and get the bigger mail at night ? or have you something else in mind. When you run 'maildirsmtp', that in turn runs maildirserial which runs tcpclient which runs serialsmtp. Changing maildirsmtp's operation to, for example, handling bigger messages in a separate thread, would only require patching/replacing maildirserial to spawn two tcpclient+serialsmtp's instead of one. Filtering at delivery seems useless to me because that would mean you spread your mail over 2 Maildirs. Greetz, Peter. -- [EMAIL PROTECTED] - Peter van Dijk [student:developer:ircoper]
Re: Sort maildir and send smallest first
On Wed, Jul 26, 2000 at 08:45:34AM +0600, [EMAIL PROTECTED] wrote: [snip] I would like to have qmail changed to do a sort mailbox by seize and send the smallest first. My reason is that I might have someone with a large 1-2 MB attachment to be sent and I do not like to send that during daytime when phone charges are very high, but would like to send smaller messages first and then I let cron cut the connection after x minutes. The larger messages could then go at night where the x minutes is set to a higher value. I have considered a similar change, having 2 maildirsmtp's running, one for mails under 32kbyte, one for bigger mails. That would do too. Looking at how maildirsmtp works, this shouldn't be that hard. Greetz, Peter. -- [EMAIL PROTECTED] - Peter van Dijk [student:developer:ircoper]