> That's what I've done too. Users can add their own subdomains, mailboxes
> ... The main parts are dbmail, PowerDNS and PureFTP. Apache configs are
> generated from database content.
>
> I did that in PHP, this is the code I use to add a new mail user (should
> be self explaining I hope):
>
> // ---------------------------------------------------------
> // $mboxname (=dbmail user) is something like [EMAIL PROTECTED]
> function dbMailboxesAddBox($userid, $mboxname, $password) {
>
> global $dbh;
> if (!is_numeric($userid)) die("Internal error file " . __FILE__ .
> ",line " . __LINE__);
>
> // we always create lowercase mailboxes
> $mboxname = strtolower($mboxname);
>
> // get the new id ------------------------------
> $newMboxId = dbGetSequenceId(DB_TABLE_USERS_SEQ);
>
> dbBegin();
> // create the new user -------------------------
> //INSERT INTO users
> (user_idnr,userid,passwd,client_idnr,maxmail_size,encryption_type)
> //VALUES (7, '[EMAIL PROTECTED]','passwort',999,'1000','')
> $query = "INSERT INTO " . DB_TABLE_USERS
> . " (" . DB_TABLE_USERS_ROW_ID . ","
> . DB_TABLE_USERS_ROW_MBOX . ","
> . DB_TABLE_USERS_ROW_PASSWD . ","
> . DB_TABLE_USERS_ROW_CLIENT_ID . ","
> . DB_TABLE_USERS_ROW_MAXMAILSIZE . ","
> . DB_TABLE_USERS_ROW_ENCRYPTION . ")"
> . " VALUES (" . $newMboxId . ","
> . sqlQuote($mboxname) . ","
> . sqlQuote($password) . ","
> . $userid . ","
> . MAIL_QUOTA . ","
> . "'')";
> $result = $dbh->query($query);
>
> // sanity checks
> if ((DB::isError($result)) || ($dbh->affectedRows() != 1)) {
> dbError("dbMailboxesAddBox", $query, $result); exit; }
>
> // create the new INBOX ------------------------
> //INSERT INTO mailboxes (owner_idnr, name) VALUES (7,'INBOX')
> $query = "INSERT INTO " . DB_TABLE_USERMAILBOX
> . " (" . DB_TABLE_USERMAILBOX_ROW_OWNER . ","
> . DB_TABLE_USERMAILBOX_ROW_NAME . ")"
> . " VALUES (" . $newMboxId
> . ",'INBOX')";
> $result = $dbh->query($query);
>
> // sanity checks
> if ((DB::isError($result)) || ($dbh->affectedRows() != 1)) {
> dbError("dbMailboxesAddBox", $query, $result); exit; }
>
> dbLog("info", "addMailbox " . $newMboxId . " (" . $mboxname . ")");
> dbCommit();
> }
well. this is good. Can you share the code to others and attach it here so
that others can try and make improvements on it? I really need this.