SQL to Add User for Developers

Author: Kevin Baker

Below are SQL queries that can be used by developers to build new admin interfaces to DBMail. I'm using these queries to start my Java API to administrate DBMail. Right now I just have DbmailUtil.addUser(User user). I'll post as soon as I have it a bit more complete…

Add User

INSERT USER

INSERT INTO dbmail_users 
  (userid,passwd,client_idnr,maxmail_size,encryption_type,last_login) VALUES 
  ('[userid]','[password]',0,'QUOTA IN BYTES','',CURRENT_TIMESTAMP)

GET USER_IDNR

[user_idnr] = SELECT user_idnr FROM dbmail_users WHERE userid='[userid]'

CREATE MAILBOX FOR USER_IDNR

INSERT INTO dbmail_mailboxes 
  (name, owner_idnr,seen_flag, answered_flag, deleted_flag,flagged_flag, recent_flag, draft_flag, permission) VALUES 
  ('INBOX', [user_idnr], 1, 1, 1, 1, 1, 1, 2)

DBMail (>=2.1.7) automatically created the mailbox on need. So no need to add it manually.

CREATE MAILBOX ALIAS

INSERT INTO dbmail_aliases 
  (alias,deliver_to,client_idnr) VALUES 
  ('[user email address]',[user_idnr],0)

CREATE EMAIL FORWARD

Added by: Ruslan Yalyshev

INSERT INTO dbmail_aliases 
  (alias,deliver_to,client_idnr) VALUES 
  ('[user email address]','[forward email address]',0)  
  [[http://writing-help.org/|Writing help]]
 
add-user-sql.txt · Last modified: 2011/06/01 10:46 by quentinscott
 
DBMail is developed by Paul J Stevens together with developers world-wide