From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 448561938432 X-Gmail-Labels: Topic type: DISCUSSION X-Google-Groups: supmua X-Google-Thread: 3030fda1bf,f1736d7c46cc25e2 X-Google-Attributes: gid3030fda1bf,domainid0,public,googlegroup X-Google-NewGroupId: yes X-Received: by 10.66.97.39 with SMTP id dx7mr44068201pab.29.1419862879258; Mon, 29 Dec 2014 06:21:19 -0800 (PST) X-BeenThere: supmua@googlegroups.com Received: by 10.140.38.82 with SMTP id s76ls2238070qgs.2.gmail; Mon, 29 Dec 2014 06:21:19 -0800 (PST) X-Received: by 10.140.92.176 with SMTP id b45mr21164qge.10.1419862879001; Mon, 29 Dec 2014 06:21:19 -0800 (PST) X-Google-Doc-Id: be811fab941ead3 X-Google-Web-Client: true Date: Mon, 29 Dec 2014 06:21:18 -0800 (PST) From: Matthew Bloch To: supmua@googlegroups.com Message-Id: <4dd537d6-3651-4040-b313-c271e0842fbe@googlegroups.com> In-Reply-To: References: Subject: Re: Best hacks for multiple sent_source folders MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_366_1331477675.1419862878241" X-Google-Token: EN7GhaUFdGScZ0mmDd40 X-Google-IP: 81.187.33.217 ------=_Part_366_1331477675.1419862878241 Content-Type: multipart/alternative; boundary="----=_Part_367_1365681985.1419862878241" ------=_Part_367_1365681985.1419862878241 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Well, I'm not too proud, but this on a cron job does what I need! If I get some time to dig into the sup source, I might have a stronger opinion about how/whether to integrate this sort of thing. My instinct is "no", sup copes with messages being moved around under it, and offlineimap does the right thing too. #!/usr/bin/ruby require 'mail' BASE = "/home/mattbee/mail" SOURCE = "#{BASE}/sup.sent" FROM_ADDRESS_TO_SENT_FOLDER_MAP = { "matthew@work" => "#{BASE}/Work/Sent", "matthew@personal" => "#{BASE}/Personal/Sent", "matthew@othercompany" => "#{BASE}/Othercompany/Sent" } %w( cur new ).each do |d| d = "#{SOURCE}/#{d}" Dir.new(d).entries.each do |e| f = "#{d}/#{e}" next unless File.file?(f) mail = Mail.read(f) maildir = FROM_ADDRESS_TO_SENT_FOLDER_MAP[mail.from.first] if !maildir STDERR.print "Unknown From address in #{f}\n" else # STDERR.print "Moving #{f} to #{maildir}\n" File.rename(f, "#{maildir}/cur/#{e}") end end end ------=_Part_367_1365681985.1419862878241 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Well, I'm not too proud, but this on a cron job does what = I need! If I get some time to dig into the sup source, I might have a stron= ger opinion about how/whether to integrate this sort of thing. My instinct = is "no", sup copes with messages being moved around under it, and offlineim= ap does the right thing too.

#!/usr/bin/ruby
require 'mail'
BASE =3D "/home/mattbee/mail"

SOURCE =3D "#{BASE}/sup.sent"
FROM_ADDRESS_TO_SENT_FOLDER_MAP =3D {
  "matthew@work" =3D> "#{= BASE}/Work/Sent",
  "matthew@personal" =3D> "#{BASE}/Personal/Se= nt",
  "matthew@othercompany" =3D> "#{BASE}/Othercompany/Sent"}

%w( cur new ).each do |d|
  d =3D "#{SOURCE}/#{d}"
&n= bsp; Dir.new(d).entries.each do |e|
    f =3D "#{d}/#{e}"=
    next unless File.file?(f)
    mail= =3D Mail.read(f)
    maildir =3D FROM_ADDRESS_TO_SENT_FO= LDER_MAP[mail.from.first]
    if !maildir
  =     STDERR.print "Unknown From address in #{f}\n"
 &= nbsp;  else
#      STDERR.print "Moving #{= f} to #{maildir}\n"
      File.rename(f, "#{mai= ldir}/cur/#{e}")
    end
  end
end


=
------=_Part_367_1365681985.1419862878241-- ------=_Part_366_1331477675.1419862878241--