Copy emails into a new address?

lbohn

New Member
I need to copy emails from an existing address into a newly created address for one of my users.

I login to my VPS via PuTTY and am using the following command, inserting the proper info where needed:
Code:
cp /home/USER/mail/ACCOUNT/EMAIL1/cur /home/USER/mail/ACCOUNT/EMAIL2/new
The files copy into the directory, however when I login via webmail, the emails are shown as "Unknown Sender" and "Unknown Receipent" in SquirrelMail or simply error out in Mail2Web.com.

Do I need to rebuild a mail database to have the copied emails display correctly? If so, how do I do that? Or is there a better way to do what I am trying to do? I appreciate any advice from those with more Linux knowledge than myself (which isn't much:)).

Thanks.
 
I bet this could be related to wrong ownership. Try to run the following command to fix the files ownership:

chown -R USER:USER /home/USER/mail/ACCOUNT/EMAIL2

Please be very careful with recursive flags - little mistake in the arguments could render the system totally unusable
 
Thanks for the quick reply Paul!

The only variables changing are EMAIL1 and EMAIL2. USER and ACCOUNT are exactly the same for each address. USER happens to be the name of the cPanel account, automagically created when the VPS was setup. ACCOUNT is the USER name + ".com", also automagically created for me.

As I understand Linux and permissions, the Linux user is USER and EMAIL1 and EMAIL2 are just directories, presumably already owned by USER. Is that correct? The chown command is then simply setting the owner to USER, even if the owner is already USER? Should chown be run on /home/USER/mail/ACCOUNT/EMAIL2 or just on /home/USER/mail/ACCOUNT/EMAIL2/new?

Thanks.
 
If you run the original "cp" command while you was logged in as root all destination files will be owned by root, to preserve ownership and permissions "-p" cp's option needs to be used. If "-p" wasn't used then just run the chown command to fix ownership.
Run chown for the whole /home/USER/mail/ACCOUNT/EMAIL2 directory as emails might have been moved from "new" to "cur" already. At any rate on cPanel systems all files in /home/USER/mail/ should belong to USER account and USER group.
 
Thanks again for the quick reply Paul!

I've only been using cp on 1 file, to test out the copy, so I will retry with -p. Good to have the explanation on chown.

Thanks.
 
Top