Re: How to copy messages between mailboxes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 25, 2009 at 05:45:25PM -0500, Jason Voorhees wrote:
> Hi people:
> 
> I'm trying to create a script to copy "certain" messages from a
> mailbox of user A to mailbox of user B. These are the steps I have in
> mind:
 
Wrong steps.  That's not a good way to do it.

> # mkdir /var/spool/imap/a/user/B/Recent
> # cd /var/spool/imap/a/user/A
> # cp 234. 235. 236. Drafts/12* /var/spool/imap/a/user/B/Recent
> # chown -R cyrus:mail /var/spool/imap/a/user/B/Recent
> # su cyrus -c '/usr/lib/cyrus-imapd/reconstruct -r user/B'

Use IMAP.

a) Connect as an admin (with permissions on both user.A and user.B)

b) CREATE user.B.Recent

c) SELECT user.A
d) UID COPY 234,235,236 user.B.Recent

e) SELECT user.A.Drafts
f) UID COPY 12:* user.B.Recent

------------

Much cleaner, and you get all the locking goodness of doing it the
RIGHT way.

An alternative to being admin is just adding read ACLs for user
B on user A's folders (as user A), then logging in as user B and
doing these steps.

You can use any IMAP client library.  We use Perl Mail::ImapTalk,
but whatever language you're familiar with is fine.

Bron.
----
Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html

[Index of Archives]     [Cyrus SASL]     [Squirrel Mail]     [Asterisk PBX]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [KDE]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux