It is possible for Sympa to store its user information in files but WWSympa need to use a relational database. Currently you can use one of the following RDBMS : MySQL, PostgreSQL, Oracle, Sybase. Interfacing with other RDBMS requires only a few changes in the code, since the API used, DBI (DataBase Interface), has DBD (DataBase Drivers) for many RDBMS.
You need to have a DataBase System installed (not necessarily on the same host as Sympa), and the client libraries for that Database installed on the Sympa host ; provided, of course, that a PERL DBD (DataBase Driver) is available for your chosen RDBMS! Check the DBI Module Availability.
Sympa will use DBI to communicate with the database system and
therefore requires the DBD for your database system. DBI and
DBD::YourDB (Msql-Mysql-modules for MySQL) are distributed as
CPAN modules. Refer to
, page
for installation
details of these modules.
The sympa database structure is slightly different from the structure of a subscribers file. A subscribers file is a text file based on paragraphs (similar to the config file) ; each paragraph completely describes a subscriber. If somebody is subscribed to two lists, he/she will appear in both subscribers files.
The DataBase distinguishes information relative to a person (e-mail, real name, password) and his/her subscription options (list concerned, date of subscription, reception option, visibility option). This results in a separation of the data into two tables : the user_table and the subscriber_table, linked by a user/subscriber e-mail.
The create_db script below will create the sympa database for you. You can find it in the script/ directory of the distribution (currently scripts are available for MySQL, PostgreSQL, Oracle and Sybase).
## MySQL Database creation script CREATE DATABASE sympa; ## Connect to DB \r sympa CREATE TABLE user_table ( email_user varchar (100) NOT NULL, gecos_user varchar (150), password_user varchar (40), cookie_delay_user int, lang_user varchar (10), PRIMARY KEY (email_user) ); CREATE TABLE subscriber_table ( list_subscriber varchar (50) NOT NULL, user_subscriber varchar (100) NOT NULL, date_subscriber datetime NOT NULL, update_subscriber datetime, visibility_subscriber varchar (20), reception_subscriber varchar (20), bounce_subscriber varchar (30), comment_subscriber varchar (150), PRIMARY KEY (list_subscriber, user_subscriber), INDEX (user_subscriber,list_subscriber) );
-- PostgreSQL Database creation script
CREATE DATABASE sympa;
-- Connect to DB
\connect sympa
DROP TABLE user_table;
CREATE TABLE user_table (
email_user varchar (100) NOT NULL,
gecos_user varchar (150),
cookie_delay_user int4,
password_user varchar (40),
lang_user varchar (10),
CONSTRAINT ind_user PRIMARY KEY (email_user)
);
DROP TABLE subscriber_table;
CREATE TABLE subscriber_table (
list_subscriber varchar (50) NOT NULL,
user_subscriber varchar (100) NOT NULL,
date_subscriber datetime NOT NULL,
update_subscriber datetime,
visibility_subscriber varchar (20),
reception_subscriber varchar (20),
bounce_subscriber varchar (30),
comment_subscriber varchar (150),
CONSTRAINT ind_subscriber PRIMARY KEY (list_subscriber, user_subscriber)
);
CREATE INDEX subscriber_idx ON subscriber_table (user_subscriber,list_subscriber);
/* Sybase Database creation script 2.5.2 */
/* Thierry Charles <tcharles@electron-libre.com> */
/* 15/06/01 : extend password_user */
/* sympa database must have been created */
/* eg: create database sympa on your_device_data=10 log on your_device_log=4 */
use sympa
go
create table user_table
(
email_user varchar(100) not null,
gecos_user varchar(150) null ,
password_user varchar(40) null ,
cookie_delay_user numeric null ,
lang_user varchar(10) null ,
constraint ind_user primary key (email_user)
)
go
create index email_user_fk on user_table (email_user)
go
create table subscriber_table
(
list_subscriber varchar(50) not null,
user_subscriber varchar(100) not null,
date_subscriber datetime not null,
update_subscriber datetime null,
visibility_subscriber varchar(20) null ,
reception_subscriber varchar(20) null ,
bounce_subscriber varchar(30) null ,
comment_subscriber varchar(150) null ,
constraint ind_subscriber primary key (list_subscriber, user_subscriber)
)
go
create index list_subscriber_fk on subscriber_table (list_subscriber)
go
create index user_subscriber_fk on subscriber_table (user_subscriber)
go
## Oracle Database creation script
## Fabien Marquois <fmarquoi@univ-lr.fr>
/Bases/oracle/product/7.3.4.1/bin/sqlplus loginsystem/passwdoracle <<-!
create user SYMPA identified by SYMPA default tablespace TABLESP
temporary tablespace TEMP;
grant create session to SYMPA;
grant create table to SYMPA;
grant create synonym to SYMPA;
grant create view to SYMPA;
grant execute any procedure to SYMPA;
grant select any table to SYMPA;
grant select any sequence to SYMPA;
grant resource to SYMPA;
!
/Bases/oracle/product/7.3.4.1/bin/sqlplus SYMPA/SYMPA <<-!
CREATE TABLE user_table (
email_user varchar2(100) NOT NULL,
gecos_user varchar2(150),
password_user varchar2(40),
cookie_delay_user number,
lang_user varchar2(10),
CONSTRAINT ind_user PRIMARY KEY (email_user)
);
CREATE TABLE subscriber_table (
list_subscriber varchar2(50) NOT NULL,
user_subscriber varchar2(100) NOT NULL,
date_subscriber date NOT NULL,
update_subscriber date,
visibility_subscriber varchar2(20),
reception_subscriber varchar2(20),
bounce_subscriber varchar2 (30),
comment_subscriber varchar2 (150),
CONSTRAINT ind_subscriber PRIMARY KEY (list_subscriber,user_subscriber)
);
!
You can execute the script using a simple SQL shell such as mysql or psql.
Example:
# mysql < create_db.mysql
You can import subscribers data into the database from a text file having one entry per line : the first field is an e-mail address, the second (optional) field is the free form name. Fields are spaces-separated.
Example:
## Data to be imported ## email gecos john.steward@some.company.com John - accountant mary.blacksmith@another.company.com Mary - secretary
To import data into the database :
cat /tmp/my_import_file | sympa.pl --import=my_list
(see 3.6, page
).
If a mailing list was previously setup to store subscribers into subscribers file (the default mode in versions older then 2.2b) you can load subscribers data into the sympa database. The simple way is to edit the list configuration using WWSympa (this requires listmaster privileges) and change the data source from file to database ; subscribers data will be loaded into the database at the same time.
If the subscribers file is too big, a timeout may occur with the FastCGI (.com P>
example : su sympa -c "touch ~sympa/spool/outgoing/.rebuild.sympa-fr@cru.fr"
You can also rebuild web archives from within the admin page of the list.
WWSympa needs an RDBMS (Relational Database Management System) in order to run. All database access is performed via the Sympa API. Sympa currently interfaces with MySQL, PostgreSQL, Oracle and Sybase.
A database is needed to store user passwords and preferences. The database structure is documented in the Sympa documentation ; scripts for creating it are also provided with the Sympa distribution (in script).
User information (password and preferences) are stored in the «User» table. User passwords stored in the database are encrypted using reversible RC4 encryption controlled with the cookie parameter, since WWSympa might need to remind users of their passwords. The security of WWSympa rests on the security of your database.