CREATE TABLE mgw_webmail_accounts (
  mailboxname CHARACTER VARYING(255) default NULL,
  servertype CHARACTER VARYING(20) default NULL,
  pophost CHARACTER VARYING(255) default NULL,
  smtphost CHARACTER VARYING(255) default NULL,
  smtpauth CHARACTER VARYING(10) default NULL,
  smtpusepopuser CHARACTER VARYING(10) default NULL,
  usemailfunction CHARACTER VARYING(10) default NULL,
  smtpusername CHARACTER VARYING(255) default NULL,
  smtppassword CHARACTER VARYING(255) default NULL,
  username CHARACTER VARYING(255) default NULL,
  password CHARACTER VARYING(255) default NULL,
  leavemessages CHARACTER VARYING(10) default NULL,
  popbeforesmtp CHARACTER VARYING(10) default NULL,
  enable_ssl CHARACTER VARYING(10) default NULL,
  enable_ssl_smtp CHARACTER VARYING(10) default NULL,
  activated CHARACTER VARYING(10) default NULL,
  fullname CHARACTER VARYING(255) default NULL,
  replyto CHARACTER VARYING(255) default NULL,
  usermaychange CHARACTER VARYING(10) NOT NULL default 'checked',
  user_id INTEGER NOT NULL default '0',
  leaveoldmails TEXT,
  id INTEGER NOT NULL default '0',
  PRIMARY KEY  (id)
);

CREATE TABLE mgw_webmail_mailboxes (
  mbox_id INTEGER NOT NULL default '0',
  user_id INTEGER NOT NULL default '0',
  mboxname CHARACTER VARYING(255) default NULL,
  mboxparent INTEGER NOT NULL default '0',
  mbox_type INTEGER NOT NULL default '3',
  mbox_protect INTEGER NOT NULL default '0',
  isintrash CHAR(1) NOT NULL default '',
  isdraft CHAR(1) NOT NULL default '',
  readflag CHAR(1) NOT NULL default '',
  readexception TEXT,
  writeflag CHAR(1) NOT NULL default '',
  writeexception TEXT,
  delflag CHAR(1) NOT NULL default '',
  delexception TEXT,
  createsubdir CHAR(1) NOT NULL default '',
  createsubexception TEXT,
  owner CHARACTER VARYING(100) NOT NULL default '',
  addowner TEXT,
  storeallflag CHAR(1) NOT NULL default '',
  storeallexception TEXT,
  PRIMARY KEY  (mbox_id)
);

CREATE TABLE mgw_webmail_messages (
  message_id INTEGER NOT NULL default '0',
  uid CHARACTER VARYING(255) NOT NULL default '',
  type CHARACTER VARYING(10) NOT NULL default '',
  encoding INTEGER default NULL,
  companies_id INTEGER default NULL,
  contact_id INTEGER default NULL,
  forumthreads_id INTEGER default NULL,
  groups_id INTEGER default NULL,
  projects_id INTEGER default NULL,
  mbox_id INTEGER NOT NULL default '0',
  user_id INTEGER NOT NULL default '0',
  header_from TEXT default NULL,
  header_to TEXT default NULL,
  header_cc TEXT default NULL,
  header_bcc TEXT default NULL,
  header_replyto CHARACTER VARYING(255) NOT NULL default '',
  header_date CHARACTER VARYING(100) NOT NULL default '',
  header_subject CHARACTER VARYING(255) NOT NULL default '',
  header_size CHARACTER VARYING(40) NOT NULL default '',
  header_inreplyto CHARACTER VARYING(255) NOT NULL default '',
  msg_body CHARACTER VARYING(255) NOT NULL default '',
  msg_cache CHARACTER VARYING(255) NOT NULL default '',
  account_name CHARACTER VARYING(255) NOT NULL default '',
  recentbit CHAR(1) NOT NULL default '',
  readbit CHAR(1) NOT NULL default '',
  replybit CHAR(1) NOT NULL default '',
  draftbit CHAR(1) NOT NULL default '',
  flaggedbit CHAR(1) NOT NULL default '',
  forwardbit CHAR(1) NOT NULL default '',
  attachbit CHAR(1) NOT NULL default '',
  replied TEXT default NULL,
  replied2 INTEGER default NULL,
  forwarded TEXT default NULL,
  forward_draft INTEGER NOT NULL default '0',
  reply_draft INTEGER NOT NULL default '0',
  PRIMARY KEY  (message_id)
);

INSERT INTO mgw_config VALUES (0,'wm2_sort',1,'wm2_sort_unsorted',0,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_emailsperpage',1,'',10,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_signature',1,'',0,'Some default Signature',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_addsignature',1,'',1,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_height_top',1,'',88,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_waittime',1,'',5,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_antispam',1,'',0,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_sortbyaccount',1,'',0,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_showstructure',1,'',1,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_enabledownload',1,'',0,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_enableinline',1,'',1,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_securehtmlmails',1,'',1,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_enablefetchnotify',1,'',1,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_fetchnotifytime',1,'',120,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_dontdownloadobjects',1,'',0,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_performvirusscan',1,'',0,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_antivirusprog',1,'/usr/local/f-prot/f-prot',0,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_antivirusprogoptions',1,'',0,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_always_recache',1,'',0,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_always_showhtml',1,'',0,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_showshort_from_to',1,'',1,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_show_size_in_maillist',1,'',0,'',1,'2002-01-01');
INSERT INTO mgw_config VALUES (0,'wm2_disable_ext',1,'',0,'exe, vbs, pif, com, wsh, bat, cmd, sys, dll',1,'2002-01-01');

INSERT INTO mgw_configtags VALUES ('wm2_height_top','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_waittime','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_sort','webmail2','',0,0,'str',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_emailsperpage','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_signature','webmail2','',0,0,'txt',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_addsignature','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_antispam','webmail2','',0,0,'str',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_sortbyaccount','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_showstructure','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_enabledownload','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_enableinline','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_securehtmlmails','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_enablefetchnotify','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_fetchnotifytime','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_dontdownloadobjects','webmail2','',0,0,'str',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_performvirusscan','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_antivirusprog','webmail2','',0,0,'str',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_antivirusprogoptions','webmail2','',0,0,'str',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_always_recache','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_always_showhtml','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_showshort_from_to','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_show_size_in_maillist','webmail2','',0,0,'int',1,'2002-01-01');
INSERT INTO mgw_configtags VALUES ('wm2_disable_ext','webmail2','',0,0,'txt',1,'2002-01-01');

INSERT INTO mgw_webmail_mailboxes (mbox_id, user_id, mboxname, mboxparent, mbox_type, mbox_protect,isintrash) VALUES (1, 0,'public', 0,0,1,0);
INSERT INTO mgw_webmail_mailboxes (mbox_id, user_id, mboxname, mboxparent, mbox_type, mbox_protect,isintrash) VALUES (2, 0,'publictrash', 0,6,1,1);

INSERT INTO mgw_webmail_accounts (usermaychange,mailboxname, servertype, pophost, smtphost, smtpauth, smtpusepopuser, usemailfunction, smtpusername, smtppassword, username, password, leavemessages, popbeforesmtp, enable_ssl, enable_ssl_smtp, activated, fullname, replyto, user_id, leaveoldmails, id) VALUES ('checked','default', 'wm2_servertype_pop3', 'pop3host', 'smtphost', '', '', '', '', '', '$username', '', '', '', '', '', 'checked', '$fullusername', '$email', 1, NULL, 0);
   
