• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Forwarding an entire mailbox?

Eric Pretorious

Regular Pleskian
A client has requested that one of their e-mail addresses (e.g., [email protected]) be forwarded to another of their e-mail addresses (e.g., [email protected]) but there are already a few hundred e-mail messages in Fred's mailbox.

Is there an easy way to move those messages from Fred's mail spool to to Barney's mail spool?
 
You can copy the email contents directly through SHELL with

Code:
scp -r /var/qmail/mailnames/from_domain.com/from_email/* /var/qmail/mailnames/to_domain.com/to_email/*
chown -R popuser:popuser /var/qmail/mailnames/to_domain.com/*
 
You can copy the email contents directly through SHELL with

Code:
scp -r /var/qmail/mailnames/from_domain.com/from_email/* /var/qmail/mailnames/to_domain.com/to_email/*
chown -R popuser:popuser /var/qmail/mailnames/to_domain.com/*

Thanks, Abdi:

Can/Should I copy the contents of Fred's Maildir/cur subdirectory to Barney's Maildir/new subdirectory? e.g.,

Code:
[root@www fred]# tree -d
.
├── @attachments
└── Maildir
    ├── courierimapkeywords
    ├── [COLOR="#00FF00"]cur[/COLOR]
    ├── [COLOR="#FF0000"]new[/COLOR]
    └── tmp
Or is there some metadata or tagging that would interfere with placing the current messages in the Maildir/new subdirectory?
 
Thanks, Abdi:

Can/Should I copy the contents of Fred's Maildir/cur subdirectory to Barney's Maildir/new subdirectory?... Or is there some metadata or tagging that would interfere with placing the current messages in the Maildir/new subdirectory?
And what about the contents of the maildirsize and courierimapuiddb files? Will moving the files into the subdirectories cause errors will these data files?
Code:
[root@mail fred]# for x in maildirsize courierimapuiddb ; do echo -e "\n$x\n============" ; head Maildir/$x ; done

maildirsize
============
0S,0C
           0           0
        2236            1
        1901            1
         896            1
        4706            1
        7240            1
        7464            1
        7329            1
        7400            1

courierimapuiddb
============
1 1379734202 136
1 1379734173.M370392P21576V000000000000CA01I000000000011C174.mail.example.com,S=2236
2 1379734251.M683539P21962V000000000000CA01I000000000011C182.mail.example.com,S=1901
3 1379736216.M56489P30712V000000000000CA01I000000000011C1D7.mail.example.com,S=4706
4 1379737258.M761139P31494V000000000000CA01I000000000011C1DD.mail.example.com,S=7240
5 1379737259.M89796P31511V000000000000CA01I000000000011C1F4.mail.example.com,S=7464
6 1379737530.M838652P31639V000000000000CA01I000000000011C1EE.mail.example.com,S=7329
7 1379743070.M470047P17169V000000000000CA01I000000000011C1F6.mail.example.com,S=7400
8 1379745047.M24357P21357V000000000000CA01I000000000011C200.mail.example.com,S=2664
9 1379749204.M947796P23740V000000000000CA01I000000000011C2BB.mail.example.com,S=7721
e.g., If I copy the files from fred/Mailbox/cur to barney/Mailbox/new, Firebird/Iceweasel complains when retrieving mail for Barney:

The RETR command did not succeed. Error retrieving a message. Mail server example.com responded: Can't open the message file - it's gone!
 
You can copy the email contents directly through SHELL with

Code:
chown -R popuser:popuser /var/qmail/mailnames/to_domain.com/*

And what about the contents of the maildirsize and courierimapuiddb files? Will moving the files into the subdirectories cause errors will these data files? ...e.g., If I copy the files from fred/Mailbox/cur to barney/Mailbox/new, Firebird/Iceweasel complains when retrieving mail for Barney:
The RETR command did not succeed. Error retrieving a message. Mail server example.com responded: Can't open the message file - it's gone!

The error was caused because I forgot to change the filesystem ownership. i.e., This command resolved the errors (just as Abdi had instructed):
Code:
[root@mail mailnames]# chown popuser:popuser example.com/BarneyMaildir/cur/*
 
Last edited:
Safest way to copy mailboxes would be to use some kind of IMAP migration tool like imapsync.

That said, copying with cp -ar with the exception of courier* metadata files would do the trick as well. That way IMAP keywords may be lost, but this is OK in this case. Quota will be automatically recalculated some time in the future upon mail delivery.
 
Back
Top