42 |
rodolico |
1 |
archiveIMAP copies or moves mail from one account to another. The action is calculated based on the configuration file
|
|
|
2 |
archiveIMAP.yaml which must exist in the same directory. The configuration file may contain information on any number of account
|
|
|
3 |
pairs, each of which is individually configurable. The script will process them in a random order (they are a Perl hash), but
|
|
|
4 |
all accounts which have the enabled flag on will be processed during a given run.
|
|
|
5 |
|
108 |
rodolico |
6 |
NOTE: the actual configuration file is yaml (archiveIMAP.yaml), but I'm better at Perl structures, so the samples are written
|
|
|
7 |
in archiveIMAP.cfg.sample (Perl), then converted to archiveIMAP.yaml.sample using the included utility confToYAML.pl.
|
|
|
8 |
|
|
|
9 |
Two utilities are provided:
|
|
|
10 |
|
|
|
11 |
confToYAML.pl - reads a perl structure from stdin, returns the YAML equivilent to stdout
|
|
|
12 |
YAMLToconf.pl - Reads the file archiveIMAP.yaml and dumps it to stdout as a perl structure (NOTE, name of hashref should be changed)
|
|
|
13 |
|
42 |
rodolico |
14 |
The configuration file is broken into two sections, default and accounts. Default values are also included in the script itself.
|
|
|
15 |
Order of precedence, from lowest to highest is:
|
|
|
16 |
|
|
|
17 |
script defaults
|
|
|
18 |
default section of configuration file
|
|
|
19 |
account section of configuration file
|
|
|
20 |
|
|
|
21 |
Default selections are:
|
|
|
22 |
|
|
|
23 |
account is enabled (enabled = 1)
|
|
|
24 |
testing is disabled (testing = 0)
|
|
|
25 |
|
|
|
26 |
For target
|
|
|
27 |
hierarchy = <path> (use original source path on target server)
|
|
|
28 |
server = localhost
|
|
|
29 |
For source
|
108 |
rodolico |
30 |
age = 1 year (archive anything older than this). This is the same as 365 and 12M
|
42 |
rodolico |
31 |
delete empty folders is disabled (deleteEmptyFolders = 0)
|
|
|
32 |
delete original message is disabled (deleteOnSuccess = 0
|
|
|
33 |
server = localhost
|
|
|
34 |
system folders = Outbox, Sent Items, INBOX
|
|
|
35 |
ignored folders = Deleted Messages, Drafts, Junk E-mail, Junk, Trash
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
Again, by simply entering corresponding values into the default section of the configuration file, these values can be overridden.
|
|
|
39 |
For example, if your "normal" source server is smtp.example.com and your "normal" target server is archives.example.com, you
|
|
|
40 |
can enter those in the default section of the configuration file.
|
|
|
41 |
|
|
|
42 |
==== hierarchy =====
|
|
|
43 |
|
|
|
44 |
This is a pattern that will be used to generate the folder names on the target server. It can be any combination of
|
|
|
45 |
|
|
|
46 |
<path> - the original path on the source server
|
|
|
47 |
<year> - the four year part of the Date entry in a particular message header
|
|
|
48 |
<month>- the two digit month part of the Date entry in a particular message header
|
|
|
49 |
constant - constants will be placed as is. Be careful, there is no checking on that.
|
|
|
50 |
|
|
|
51 |
The delimiters for the hierarchy is the caret (^) since that seems to be the most innocuous.
|
|
|
52 |
|
|
|
53 |
To build an archive that has all e-mail separated only by the year and month they were sent, use:
|
|
|
54 |
<year>^<month>
|
|
|
55 |
|
|
|
56 |
If you would like the original tree, but again, with year and month, use
|
|
|
57 |
<path>^<year>^<month>
|
|
|
58 |
|
|
|
59 |
If you would like to put the word "Archives" in there, between the old path and the date/time, you could do
|
|
|
60 |
<path>^Archives^<year>^<month>
|
108 |
rodolico |
61 |
|
|
|
62 |
|
|
|
63 |
==== master user ====
|
|
|
64 |
|
|
|
65 |
dovecot has the ability to be configured with one or more master users
|
|
|
66 |
(see https://doc.dovecot.org/configuration_manual/authentication/master_users/), allowing this script to be run without knowledge
|
|
|
67 |
of a users credentials. This has been added as of this version with the addition of the keys
|
|
|
68 |
adminUsername
|
|
|
69 |
adminPassword
|
|
|
70 |
adminSeparator
|
|
|
71 |
Which can be placed in the source and/or target, and either in the default or individual accounts.
|