Hi all - I'm about to move on of our mailservers onto dbmail as part of our first production environment; and was wondering the best way to propogate the database, etc with information.
1) Porting mailboxes Obviously I'll use the existing utilities here to handle this; but was wondering if anyone had a utility already written which also checked the users' home directory for IMAP mailboxes and imported them at the same time. 2) Adding new users on an ongoing system The adduser script does the job for one-by-one additions, but we already maintain a user database elsewhere. I don't want to have to call the script each time a user is added. I'd rather simply execute an SQL query or run a synchronisation script every 5 mins or something. This works in principle, by simply calling: insert into users (userid, password) values ('blah','blah') Delivering mail using dbmail-smtp -u blah works fine, but reports an error "db_check_sizelimit(): user has NO mailboxes" which make sense (I haven't added any). POP works fine and returns any test messages, but when looking at it via IMAP I get a no such folder INBOX error. I can obviously get around this by creating a mailbox using a similar SQL query, but I'm hoping to leave this table alone... I'm using two databases (dbmail_auth and dbmail_store); and only the users and aliases table are in the dbmail_store database. My objective is to only edit these tables (and later integrate them into my main authentication database when 1.0 is released), so that the dbmail internals (messages, mailboxes, etc) are never touched by me/my code (thus minimising the risk of corruption). Thus is there any way to have this mailbox created automatically? It seems to make sense to me, and would work for POP and IMAP. This I guess would also be useful if people were using the dbmail -m mailbox -u username syntax. A patch like this (for mysql, easy to port if liked) - would be something like: --- mysql/dbmysql.c_orig Sat Jul 27 14:19:06 2002 +++ mysql/dbmysql.c Sat Jul 27 14:41:04 2002 @@ -452,10 +452,38 @@ if (mysql_num_rows(res)<1) { - trace (TRACE_DEBUG,"db_get_mailboxid(): user has no mailbox named [%s]", mailbox); + trace(TRACE_ERROR,"db_get_mailboxid(): user has no mailbox named [%s] - Creating", mailbox); mysql_free_result(res); + + // create mailbox + db_createmailbox(mailbox, useridnr); + + snprintf (query, DEF_QUERYSIZE,"SELECT mailbox_idnr FROM mailboxes WHERE " + "name=\'%s\' AND owner_idnr=%llu", + mailbox, useridnr); + + // double check to see if mailbox exists now + if (db_query(query)==-1) + { + trace(TRACE_ERROR, "db_get_mailboxid(): query failed"); + return 0; + } + + if ((res = mysql_store_result(&conn)) == NULL) + { + trace(TRACE_ERROR,"db_get_mailboxid(): mysql_store_result failed: %s",mysql_error(&conn)); + return 0; + } + + if (mysql_num_rows(res)<1) + { + trace (TRACE_DEBUG,"db_get_mailboxid(): user has no mailbox named [%s]. Couldn't create.", mailbox); + mysql_free_result(res); + + return 0; + } - return 0; + // if still here, the mailbox should have been created If I'm barking up the wrong tree, can someone let me know the better way to handle this please. Cheers, Mark.