Topic: Automatically create folder

==== Required information ====
- iRedMail version: 08.6.4
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Linux/BSD distribution name and version: Ubuntu 12.04
- Related log if you're reporting an issue:

I have noticed that if I created another domain and created users on it, their corresponding mail boxes on the /var/vmail folder will not be created automatically.
For example, if i created test@domain.com, the mailbox should be in /var/vmail/vmail1/domain.com/t/e/s/test-2013.
But this folder will not be created instantly when the user is created in the Web Admin page.
Only until they received an email will their corresponding folder be created.

Is there a way to alter this behavior? I am going to create about 100 email account in 2 domains and I'm going to copy their old email from our previous email server to their roundcube mailboxes. It would be very tedious if I were to create the folders manually.

Thank you


Re: Automatically create folder

Maildir will be created while:

- When user first login, either via POP3 or IMAP
- Email received.

I think you can write a script to read maildir paths from SQL table, then create them with "mkdir -p" manually.

- You have to create sub-directoires, cur, tmp, new.
- Owner of files/directories under /var/vmail/ must be "vmail:vmail", permission "0700".


Does my reply help a little? How about buying me a cup of coffee ($5) as an encouragement?

buy me a cup of coffee


Re: Automatically create folder

Thanks, zhang. At least it would be easier to just login the user. I'm not quite very good with scripting yet.


Re: Automatically create folder

I realise this is quite an old message, but I found it when I was searching for ways to do the same thing. So here's a quick mechanism.

I had 314 users that I imported in LDIF format. That means I had a big file with all my users in it. One field in that file is mailMessageStore and it contains the full path to the unique path for each user's mail directory. So assuming you have a file named 'import.ldif' with all your LDIF entries to import, this command will get you a list of all the unique bits you need:
grep mailMessageStore import.ldif | cut -d " " -f 2

So I just wrap that in a script and create all the directories really quickly. This uses a bash shell trick that expands things in curly braces.

So this little for loop does it really well. It assumes /var/vmail is the root of your mail directory.

for userDir in $(grep mailMessageStore import.ldif | cut -d " " -f 2)
  mkdir -p "/var/vmail/${userDir}"Maildir/{cur,new,tmp}