Skip to main content

**SOLVED** Fix missing mail directories

Comments

5 comments

  • cPRex Jurassic Moderator
    Hey there! These directories aren't special in any way, and only hold content and not any passwords, so they should be easy enough to recreate. I don't have a custom script handy, but a for-loop script that goes through all the usernames on the server and recreates them would likely be the easiest method. I can tell you both cur and new have user:user ownership with 751 permissions.
    0
  • webdesires
    yeah this is what I need, some script to do this... I'm not proficient in bash or anything so cannot do it. So looking for something that will fix this issue since there is over 100 cpanel accounts :(
    0
  • cPRex Jurassic Moderator
    I'm always hesitant to post any type of custom script on the Forums because once it's out there it's available forever, and I don't want to be responsible for any damage to a server. I also don't have anything ready-made for this situation so I'd also have to do some design work. It might be best to work directly with a server administrator if you're not able to come up with a good script.
    0
  • webdesires
    I have gone ahead and figured out how to do everything I needed to, below is everything I did and how I fixed it, for anyone else in the same dire situation as I was in. So firstly I was removing all mail for default cPanel accounts on the server, because we had many accounts just building up huge amounts of useless mail. WARNING! This code will delete the /cur/ and /new/ directories, which the code below will fix.: find /home/*/mail/cur/ -exec rm -rf {} + find /home/*/mail/new/ -exec rm -rf {} +
    So this destroyed the folders causing all those accounts to now bounce mail... To fix this there are 2 commands below which recreate these folders in all cPanel accounts: for dir in /home/*/; do mkdir -- "$dir/mail/cur"; done for dir in /home/*/; do mkdir -- "$dir/mail/new"; done
    The final problem is that now all these folders are root, and the mailperm script cannot fix these folders. To fix this the below 2 commands will chown all the folders to each respective cPanel user: for i in `ls /var/cpanel/users`; do chown $i:$i /home/$i/mail/cur/; done for i in `ls /var/cpanel/users`; do chown $i:$i /home/$i/mail/new/; done
    Finally now there is just folder rights issues, which you can use cPanels mailperm script to fix everything up: /scripts/mailperm
    Thanks!
    0
  • cPRex Jurassic Moderator
    Great - I'm glad you figured out a solution!
    0

Please sign in to leave a comment.