├── NEWS ├── README ├── debian ├── compat ├── patches │ ├── series │ └── dbmail_conf ├── source │ └── format ├── dbmail.dirs ├── po │ ├── POTFILES.in │ ├── it.po │ ├── ja.po │ ├── nl.po │ └── pt_BR.po ├── watch ├── dbmail.cron.d ├── upstream.changelog ├── TODO ├── dbmail.docs ├── dbmail.manpages ├── dbmail.install ├── dbmail.logrotate ├── pgsql2mysql.sh ├── dbmail.postrm ├── copyright ├── default.dbmail ├── README.Debian ├── dbmail.preinst ├── dbmail.examples └── control ├── test-scripts ├── python │ ├── __init__.py │ └── compare.py ├── testbox ├── testsearch.imap ├── testhttp.php ├── imap │ ├── close │ ├── select.mbox │ ├── search-header.mbox │ ├── uidplus │ ├── fetch-body.mbox │ ├── select │ ├── store │ ├── mutf7 │ ├── expunge2 │ ├── search-header │ ├── default.mbox │ ├── append │ ├── copy │ ├── fetch │ ├── expunge │ ├── subscribe │ ├── fetch-body │ └── list ├── testpop.txt ├── testidle.imap ├── testauthenticate.imap ├── testimap.sh ├── testautoreply.txt ├── testlist.imap ├── testthread.imap ├── testhttp.sh ├── testappend.imap ├── teststore.imap ├── testexpunge.imap ├── testsieve.txt ├── testsort.imap ├── testlmtp2.txt ├── testcondstore.txt ├── testfetch.imap ├── dumpbt.sh ├── imapbench.py └── testlmtp.txt ├── systemd ├── dbmail.tmpfiles.in ├── dbmail-imapd.service.in ├── dbmail-lmtpd.service.in ├── dbmail-pop3d.service.in ├── dbmail-timsieved.service.in └── Makefile.am ├── ChangeLog ├── test ├── check_dbmail_message.c ├── check_dbmail_util.c └── check_dbmail_common.c ├── sql ├── mysql │ ├── 2_3_6-3_0_0.mysql │ ├── 2_3_4-2_3_5.mysql │ ├── upgrades │ │ ├── 32003.mysql │ │ ├── 32001.mysql │ │ ├── 32004.mysql │ │ └── 32002.mysql │ ├── 2_1_7-2_2_0.mysql │ ├── update_headervalue_01.mysql │ ├── 3_0_2-3_1_0.mysql │ ├── 2_3_0-2_3_2.mysql │ └── 2_2_5-2_3_0.mysql ├── sqlite │ ├── 2_3_4-2_3_5.sqlite │ ├── 2_3_6-3_0_0.sqlite │ ├── upgrades │ │ ├── 32003.sqlite │ │ ├── 32004.sqlite │ │ ├── 32001.sqlite │ │ └── 32002.sqlite │ ├── 3_0_2-3_1_0.sqlite │ ├── trigger.tmpl.sql │ └── 2_1_7-2_2_0.sqlite ├── postgresql │ ├── 2_3_6-3_0_0.pgsql │ ├── upgrades │ │ ├── 32003.psql │ │ ├── 32004.psql │ │ ├── 32001.psql │ │ └── 32002.psql │ ├── 2_3_4-2_3_5.pgsql │ ├── 3_0_2-3_1_0.psql │ ├── 2_1_7-2_2_0.pgsql │ └── 2_2_5-2_3_0.pgsql └── oracle │ ├── dbmail_ts.sql │ └── dbmail_grant.sql ├── contrib ├── startup-scripts │ ├── gentoo │ │ ├── conf.d-dbmail │ │ └── init.d-dbmail │ ├── README │ └── redhat │ │ ├── dbmail-imapd.init │ │ ├── dbmail-lmtpd.init │ │ └── dbmail-pop3d.init ├── mailbox2dbmail │ ├── README │ ├── mailbox2dbmail.yo │ └── mailbox2dbmail.1 ├── sql2sql │ ├── pgsql2mysql.sh │ ├── check_physmessage.sh │ └── mysql2pgsql.yml ├── dbmail.supp ├── nginx │ └── mail.conf ├── expiretrash.sh └── autosubscribe │ └── autosubscribe.sql ├── Makefile.am ├── AUTHORS ├── .gitignore ├── man ├── fixsp.pl ├── dbmail.conf.txt ├── dbmail-httpd.txt ├── dbmail-pop3d.txt ├── dbmail-timsieved.txt ├── dbmail-lmtpd.txt ├── footer.txt ├── commonopts.txt ├── serveropts.txt ├── dbmail.txt ├── dbmail-sievecmd.txt ├── Makefile.am ├── dbmail-deliver.txt ├── dbmail-imapd.txt └── dbmail-export.txt ├── src ├── mpool │ ├── NEWS │ ├── README │ └── ChangeLog.1 ├── sortmodule.h ├── dm_http.h ├── dm_tls.h ├── dm_cidr.h ├── dm_quota.h ├── dm_mempool.h ├── dm_digest.h ├── dm_capa.h ├── dm_cram.h ├── clientbase.h ├── dm_iconv.h ├── dm_match.h ├── sort.h ├── clientsession.h ├── lmtpd.c ├── modules │ ├── Makefile.am │ └── sortnull.c ├── dm_sset.h ├── dm_request.h ├── pop3d.c ├── imapd.c ├── dm_string.h ├── httpd.c ├── dm_list.h ├── timsieved.c ├── dm_debug.h ├── authmodule.h ├── server.h ├── dm_mailbox.h ├── dm_config.h ├── dm_digest.c ├── imapcommands.h └── dm_cram.c ├── doc ├── README.aliases ├── README.exim ├── README.smtp ├── README.sieve ├── README.solaris ├── README.filters ├── README.usermap ├── README.qmail └── README.security-password ├── m4 └── ltversion.m4 ├── jenkins ├── Makefile └── buildout.cfg ├── THANKS ├── configure.ac └── README.md /NEWS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | README.md -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /test-scripts/python/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/patches/series: -------------------------------------------------------------------------------- 1 | dbmail_conf 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /debian/dbmail.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/share/dbmail 3 | -------------------------------------------------------------------------------- /systemd/dbmail.tmpfiles.in: -------------------------------------------------------------------------------- 1 | d @piddir@ 0755 nobody nobody - 2 | -------------------------------------------------------------------------------- /debian/po/POTFILES.in: -------------------------------------------------------------------------------- 1 | [type: gettext/rfc822deb] dbmail.templates 2 | -------------------------------------------------------------------------------- /debian/po/it.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pjstevns/dbmail/HEAD/debian/po/it.po -------------------------------------------------------------------------------- /debian/po/ja.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pjstevns/dbmail/HEAD/debian/po/ja.po -------------------------------------------------------------------------------- /debian/po/nl.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pjstevns/dbmail/HEAD/debian/po/nl.po -------------------------------------------------------------------------------- /debian/po/pt_BR.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pjstevns/dbmail/HEAD/debian/po/pt_BR.po -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | 3 | http://www.dbmail.org/download/3.0/dbmail-(.*).tar.gz 4 | -------------------------------------------------------------------------------- /test-scripts/testbox: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pjstevns/dbmail/HEAD/test-scripts/testbox -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2 | Full changelog is available at: 3 | 4 | http://git.dbmail.eu/paul/dbmail/log/ 5 | -------------------------------------------------------------------------------- /test-scripts/testsearch.imap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pjstevns/dbmail/HEAD/test-scripts/testsearch.imap -------------------------------------------------------------------------------- /test/check_dbmail_message.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pjstevns/dbmail/HEAD/test/check_dbmail_message.c -------------------------------------------------------------------------------- /debian/dbmail.cron.d: -------------------------------------------------------------------------------- 1 | 0 3 * * * root test -x /usr/sbin/dbmail-util && /usr/sbin/dbmail-util -ay >/dev/null 2>&1 2 | -------------------------------------------------------------------------------- /sql/mysql/2_3_6-3_0_0.mysql: -------------------------------------------------------------------------------- 1 | 2 | CREATE UNIQUE INDEX dbmail_envelope_1 ON dbmail_envelope(physmessage_id); 3 | 4 | -------------------------------------------------------------------------------- /contrib/startup-scripts/gentoo/conf.d-dbmail: -------------------------------------------------------------------------------- 1 | 2 | # List of daemons to start. 3 | DAEMONS="lmtpd imapd pop3d timsieved" 4 | 5 | -------------------------------------------------------------------------------- /test-scripts/testhttp.php: -------------------------------------------------------------------------------- 1 | 11 | 12 | -------------------------------------------------------------------------------- /debian/upstream.changelog: -------------------------------------------------------------------------------- 1 | 2 | Please see 3 | 4 | http://github.com/pjstevns/dbmail/commits/master/ 5 | 6 | for the full commit history 7 | -------------------------------------------------------------------------------- /debian/TODO: -------------------------------------------------------------------------------- 1 | 2 | 3 | * installation of the database should be handled automatically if 4 | the database will be running on localhost. 5 | 6 | 7 | -------------------------------------------------------------------------------- /test-scripts/imap/close: -------------------------------------------------------------------------------- 1 | connections: 2 2 | 3 | 1 ok store 1,3 +flags \deleted 4 | 1 ok close 5 | 6 | 2 ok noop 7 | * $1 expunge 8 | * $3 expunge 9 | -------------------------------------------------------------------------------- /test-scripts/testpop.txt: -------------------------------------------------------------------------------- 1 | CAPA 2 | AUTH 3 | USER testuser1 4 | PASS test 5 | STAT 6 | LIST 7 | UIDL 8 | RETR 1 9 | DELE 1 10 | QUIT 11 | 12 | -------------------------------------------------------------------------------- /sql/sqlite/2_3_4-2_3_5.sqlite: -------------------------------------------------------------------------------- 1 | 2 | ALTER TABLE dbmail_mailboxes ADD seq INTEGER DEFAULT '0' NOT NULL; 3 | CREATE INDEX dbmail_mailbox_4 ON dbmail_mailboxes(seq); 4 | 5 | 6 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | SUBDIRS = src test 4 | 5 | if MANPAGES 6 | SUBDIRS += man 7 | endif 8 | 9 | if SYSTEMD 10 | SUBDIRS += systemd 11 | endif 12 | -------------------------------------------------------------------------------- /test-scripts/testidle.imap: -------------------------------------------------------------------------------- 1 | 1 login testuser1 test 2 | 2 select "INBOX" 3 | 3 getquotaroot "INBOX" 4 | 4 uid fetch 1:* (flags) 5 | 5 idle 6 | done 7 | 6 fetch 1 (UID RFC822.SIZE BODY[]) 8 | 7 logout 9 | 10 | -------------------------------------------------------------------------------- /test-scripts/testauthenticate.imap: -------------------------------------------------------------------------------- 1 | 1 capability 2 | 2 authenticate login 3 | dGVzdHVzZXIx 4 | dGVzdA== 5 | 3 select INBOX 6 | 4 idle 7 | done 8 | 5 list "" * 9 | 6 append INBOX {10} 10 | From: test 11 | 7 logout 12 | -------------------------------------------------------------------------------- /debian/dbmail.docs: -------------------------------------------------------------------------------- 1 | AUTHORS 2 | THANKS 3 | README 4 | doc/README.exim 5 | doc/README.postfix 6 | doc/README.qmail 7 | doc/README.aliases 8 | doc/README.smtp 9 | doc/README.usermap 10 | doc/README.ldap 11 | doc/README.sieve 12 | -------------------------------------------------------------------------------- /test-scripts/imap/select.mbox: -------------------------------------------------------------------------------- 1 | From user@domain Fri Feb 22 17:06:23 2008 2 | Date: Sat, 24 Mar 2007 23:00:00 +0200 3 | 4 | body 5 | 6 | From user@domain Fri Feb 22 17:06:23 2008 7 | Date: Sat, 24 Mar 2007 23:00:00 +0200 8 | 9 | body2 10 | 11 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | eelco = Eelco van Beek 2 | roel = Roel Rozendaal 3 | ilja = Ilja Booij 4 | aaron = Aaron Stone 5 | paul = Paul Stevens 6 | vulture = Jonathan Feally 7 | -------------------------------------------------------------------------------- /sql/mysql/2_3_4-2_3_5.mysql: -------------------------------------------------------------------------------- 1 | ALTER TABLE dbmail_mailboxes ADD seq bigint DEFAULT 0 NOT NULL; 2 | ALTER TABLE dbmail_mailboxes ADD KEY seq (seq); 3 | ALTER TABLE dbmail_mailboxes DROP mtime; 4 | ALTER TABLE dbmail_users MODIFY COLUMN passwd VARCHAR(130) NOT NULL; 5 | -------------------------------------------------------------------------------- /test-scripts/testimap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | _dir=`dirname $0` 4 | 5 | for f in ${_dir}/*.imap; do 6 | echo "$f" 7 | cat $f | nc -q 10 localhost 10143 8 | cat $f | openssl s_client -connect localhost:10143 -starttls imap -ign_eof 9 | done 10 | 11 | 12 | -------------------------------------------------------------------------------- /test-scripts/imap/search-header.mbox: -------------------------------------------------------------------------------- 1 | From user@domain Fri Feb 22 17:06:23 2008 2 | Subject: hello beautiful world 3 | 4 | body 5 | 6 | From user@domain Fri Feb 22 17:06:23 2008 7 | X-Extra: hello beautiful header 8 | X-Extra: another one 9 | 10 | body 11 | -------------------------------------------------------------------------------- /systemd/dbmail-imapd.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=DBMail Imap Server 3 | After=syslog.target network.target mysqld.service postgresql.service 4 | 5 | [Service] 6 | Type=notify 7 | ExecStart=@sbindir@/dbmail-imapd -D 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /systemd/dbmail-lmtpd.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=DBMail LMTP Server 3 | After=syslog.target network.target mysqld.service postgresql.service 4 | 5 | [Service] 6 | Type=notify 7 | ExecStart=@sbindir@/dbmail-lmtpd -D 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /systemd/dbmail-pop3d.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=DBMail pop3 Server 3 | After=syslog.target network.target mysqld.service postgresql.service 4 | 5 | [Service] 6 | Type=notify 7 | ExecStart=@sbindir@/dbmail-pop3d -D 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /test-scripts/testautoreply.txt: -------------------------------------------------------------------------------- 1 | LHLO host 2 | MAIL FROM: <> 3 | RCPT TO: 4 | DATA 5 | To: 6 | CC: testuser1@localhost 7 | Subject: test autoreply 8 | Reply-To: nobody@dbmail.eu 9 | From: nobody@dbmail.eu 10 | 11 | test 12 | 13 | . 14 | QUIT 15 | -------------------------------------------------------------------------------- /test-scripts/testlist.imap: -------------------------------------------------------------------------------- 1 | x login testuser1 test 2 | x list "" * 3 | x create sub1/sub2/sub3 4 | x list "" * 5 | x list "" % 6 | x unsubscribe sub1 7 | x list "" * 8 | x list "" % 9 | x delete sub1/sub2/sub3 10 | x delete sub1/sub2 11 | x delete sub1 12 | x logout 13 | 14 | -------------------------------------------------------------------------------- /debian/dbmail.manpages: -------------------------------------------------------------------------------- 1 | man/dbmail-export.8 2 | man/dbmail-imapd.8 3 | man/dbmail-lmtpd.8 4 | man/dbmail-pop3d.8 5 | man/dbmail-deliver.1 6 | man/dbmail-users.8 7 | man/dbmail-util.8 8 | man/dbmail.1 9 | man/dbmail.conf.5 10 | man/dbmail-sievecmd.8 11 | man/dbmail-timsieved.8 12 | -------------------------------------------------------------------------------- /systemd/dbmail-timsieved.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=DBMail Sieve Server 3 | After=syslog.target network.target mysqld.service postgresql.service 4 | 5 | [Service] 6 | Type=notify 7 | ExecStart=@sbindir@/dbmail-timsieved -D 8 | 9 | [Install] 10 | WantedBy=multi-user.target 11 | -------------------------------------------------------------------------------- /test-scripts/testthread.imap: -------------------------------------------------------------------------------- 1 | 1 login testuser1 test 2 | 2 select inbox 3 | 3 thread orderedsubject utf-8 header from foo.org (since 1-jan-2005) 4 | 4 thread orderedsubject utf-8 since 1-jan-2005 5 | 5 thread orderedsubject since 1-jan-2005 6 | 6 uid thread orderedsubject utf-8 1:* 7 | 6 logout 8 | -------------------------------------------------------------------------------- /debian/dbmail.install: -------------------------------------------------------------------------------- 1 | usr/sbin/dbmail-export 2 | usr/sbin/dbmail-imapd 3 | usr/sbin/dbmail-lmtpd 4 | usr/sbin/dbmail-pop3d 5 | usr/sbin/dbmail-deliver 6 | usr/sbin/dbmail-users 7 | usr/sbin/dbmail-util 8 | usr/sbin/dbmail-timsieved 9 | usr/sbin/dbmail-sievecmd 10 | usr/lib/dbmail/lib*.so* 11 | -------------------------------------------------------------------------------- /sql/postgresql/2_3_6-3_0_0.pgsql: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | DROP INDEX IF EXISTS dbmail_envelope_1; 4 | DROP INDEX IF EXISTS dbmail_envelope_2; 5 | CREATE UNIQUE INDEX dbmail_envelope_1 ON dbmail_envelope(physmessage_id); 6 | CREATE UNIQUE INDEX dbmail_envelope_2 ON dbmail_envelope(physmessage_id, id); 7 | COMMIT; 8 | 9 | -------------------------------------------------------------------------------- /sql/sqlite/2_3_6-3_0_0.sqlite: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | DROP INDEX IF EXISTS dbmail_envelope_1; 4 | DROP INDEX IF EXISTS dbmail_envelope_2; 5 | CREATE UNIQUE INDEX dbmail_envelope_1 ON dbmail_envelope(physmessage_id); 6 | CREATE UNIQUE INDEX dbmail_envelope_2 ON dbmail_envelope(physmessage_id, id); 7 | COMMIT; 8 | 9 | -------------------------------------------------------------------------------- /contrib/mailbox2dbmail/README: -------------------------------------------------------------------------------- 1 | mailbox2dbmail 2 | 3 | Author: Dan Weber 4 | 5 | Use this program to copy mail from an mbox file, maildir or mhdir directory to dbmail. 6 | This program uses ./dbmail-deliver for injecting the emails into DBMail. 7 | 8 | It needs python 2.2 or higher. 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | cscope.out 2 | *.swp 3 | *.o 4 | *.lo 5 | man/*.[0-9] 6 | autom4te.cache/ 7 | jenkins/.installed.cfg 8 | jenkins/bin/ 9 | jenkins/develop-eggs/ 10 | jenkins/eggs/ 11 | jenkins/etc/ 12 | jenkins/include/ 13 | jenkins/lib/ 14 | jenkins/local/ 15 | jenkins/parts/ 16 | jenkins/sbin/ 17 | jenkins/var/ 18 | -------------------------------------------------------------------------------- /man/fixsp.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -i 2 | 3 | my $file = $ARGV[0]; 4 | my $text = do { local( @ARGV, $/ ) = $file ; <> } ; 5 | 6 | $text =~ s/([^\n])\.sp/$1\n.sp/g; 7 | $text =~ s/\.sp\n\.sp/.sp/g; 8 | $text =~ s/\.sp\n\.SH/.SH/g; 9 | $text =~ s/\.fi\n\.RE(?!\n\.sp)/.fi\n.sp\n.RE/g; 10 | 11 | print $text; 12 | 13 | -------------------------------------------------------------------------------- /sql/mysql/upgrades/32003.mysql: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | 4 | ALTER TABLE dbmail_messages ADD seq BIGINT not null default '0'; 5 | CREATE INDEX dbmail_messages_seq_index ON dbmail_messages(seq); 6 | 7 | INSERT INTO dbmail_upgrade_steps (from_version, to_version, applied) values (32001, 32003, now()); 8 | 9 | COMMIT; 10 | -------------------------------------------------------------------------------- /sql/sqlite/upgrades/32003.sqlite: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | 4 | ALTER TABLE dbmail_messages ADD COLUMN seq INTEGER NOT NULL DEFAULT '0'; 5 | 6 | CREATE INDEX dbmail_messages_seq_index on dbmail_messages(seq); 7 | 8 | INSERT INTO dbmail_upgrade_steps (from_version, to_version) values (32001, 32003); 9 | 10 | COMMIT; 11 | -------------------------------------------------------------------------------- /sql/postgresql/upgrades/32003.psql: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | 4 | ALTER TABLE dbmail_messages ADD COLUMN seq BIGINT NOT NULL default '0'; 5 | 6 | CREATE INDEX dbmail_messages_seq_index ON dbmail_messages(seq); 7 | 8 | INSERT INTO dbmail_upgrade_steps (from_version, to_version) values (32001, 32003); 9 | 10 | COMMIT; 11 | -------------------------------------------------------------------------------- /debian/dbmail.logrotate: -------------------------------------------------------------------------------- 1 | /var/log/dbmail/*.log { 2 | daily 3 | missingok 4 | rotate 7 5 | compress 6 | delaycompress 7 | notifempty 8 | create 640 root adm 9 | sharedscripts 10 | postrotate 11 | /etc/init.d/dbmail restart > /dev/null 12 | endscript 13 | } 14 | -------------------------------------------------------------------------------- /test-scripts/testhttp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | HOST="localhost:41380" 4 | URLS="/users /users/testuser1 /users/testuser1/mailboxes /mailboxes/2/messages /messages/62820/view /messages/62820/headers/from,to,subject,date" 5 | 6 | for u in $URLS; do 7 | cmd="curl --dump - --user admin:secret http://$HOST$u" 8 | echo $cmd 9 | eval "$cmd" 10 | done 11 | 12 | 13 | -------------------------------------------------------------------------------- /sql/mysql/upgrades/32001.mysql: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | 4 | CREATE TABLE dbmail_upgrade_steps ( 5 | from_version int not null, 6 | to_version int not null, 7 | applied datetime not null, 8 | unique key (from_version, to_version) 9 | ); 10 | 11 | INSERT INTO dbmail_upgrade_steps (from_version, to_version, applied) values (0, 32001, now()); 12 | 13 | COMMIT; 14 | -------------------------------------------------------------------------------- /sql/postgresql/upgrades/32004.psql: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | ALTER TABLE dbmail_users ADD COLUMN spasswd VARCHAR(130) DEFAULT '' NOT NULL; 4 | ALTER TABLE dbmail_users ADD COLUMN saction SMALLINT DEFAULT '0' NOT NULL; 5 | ALTER TABLE dbmail_users ADD COLUMN active SMALLINT DEFAULT '1' NOT NULL; 6 | 7 | INSERT INTO dbmail_upgrade_steps (from_version, to_version) values (32001, 32004); 8 | COMMIT; 9 | -------------------------------------------------------------------------------- /sql/sqlite/upgrades/32004.sqlite: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | ALTER TABLE dbmail_users ADD COLUMN spasswd VARCHAR(130) DEFAULT '' NOT NULL; 4 | ALTER TABLE dbmail_users ADD COLUMN saction SMALLINT DEFAULT '0' NOT NULL; 5 | ALTER TABLE dbmail_users ADD COLUMN active SMALLINT DEFAULT '1' NOT NULL; 6 | 7 | INSERT INTO dbmail_upgrade_steps (from_version, to_version) values (32001, 32004); 8 | COMMIT; 9 | -------------------------------------------------------------------------------- /test-scripts/testappend.imap: -------------------------------------------------------------------------------- 1 | X login testuser1 test 2 | X list "" * 3 | X create newbox 4 | X append newbox {10} 5 | From: test 6 | X status newbox (messages unseen recent) 7 | X examine newbox 8 | X select newbox 9 | X append newbox {10} 10 | From: test 11 | X fetch 1:* flags 12 | X unselect 13 | X status newbox (messages unseen recent) 14 | X delete newbox 15 | X logout 16 | 17 | -------------------------------------------------------------------------------- /test-scripts/teststore.imap: -------------------------------------------------------------------------------- 1 | x login testuser1 test 2 | x select inbox 3 | x store 1 +flags (\Flagged) 4 | x store 1 +flags (\Flagged) 5 | x store 1 +flags.silent (\Flagged) 6 | x store 1 -flags (\Flagged) 7 | x store 1 -flags (\Answered) 8 | x store 1 +flags (Junk Trash) 9 | x store 1 -flags (Junk) 10 | x store 1 flags (\Answered Junk) 11 | x store 1 flags (\Answered) 12 | x logout 13 | -------------------------------------------------------------------------------- /sql/mysql/upgrades/32004.mysql: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | ALTER TABLE dbmail_users ADD COLUMN spasswd VARCHAR(130) DEFAULT '' NOT NULL; 4 | ALTER TABLE dbmail_users ADD COLUMN saction SMALLINT DEFAULT '0' NOT NULL; 5 | ALTER TABLE dbmail_users ADD COLUMN active SMALLINT DEFAULT '1' NOT NULL; 6 | 7 | INSERT INTO dbmail_upgrade_steps (from_version, to_version, applied) values (32001, 32004, now()); 8 | COMMIT; 9 | -------------------------------------------------------------------------------- /sql/mysql/2_1_7-2_2_0.mysql: -------------------------------------------------------------------------------- 1 | 2 | DROP TABLE IF EXISTS dbmail_envelope; 3 | CREATE TABLE dbmail_envelope ( 4 | physmessage_id BIGINT NOT NULL, 5 | id BIGINT NOT NULL AUTO_INCREMENT, 6 | envelope TEXT NOT NULL, 7 | PRIMARY KEY (id), 8 | UNIQUE (physmessage_id, id), 9 | FOREIGN KEY (physmessage_id) 10 | REFERENCES dbmail_physmessage(id) 11 | ON UPDATE CASCADE ON DELETE CASCADE 12 | ) ENGINE=InnoDB; 13 | 14 | -------------------------------------------------------------------------------- /src/mpool/NEWS: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | $Id: NEWS,v 1.2 2006/05/31 20:28:31 gray Exp $ 3 | ------------------------------------------------------------------------------- 4 | 5 | Version 2.1.0: 6 | 7 | * Added MPOOL_ERROR_PNT_OVER to show pointer overwrites. 8 | 9 | Version 2.0.0: 10 | 11 | * Initial external release of library after use since 1996. 12 | -------------------------------------------------------------------------------- /sql/sqlite/3_0_2-3_1_0.sqlite: -------------------------------------------------------------------------------- 1 | 2 | DROP VIEW IF EXISTS dbmail_datefield; 3 | CREATE VIEW dbmail_datefield AS 4 | SELECT physmessage_id,datefield,sortfield 5 | FROM dbmail_messages m 6 | JOIN dbmail_header h USING (physmessage_id) 7 | JOIN dbmail_headername n ON h.headername_id = n.id 8 | JOIN dbmail_headervalue v ON h.headervalue_id = v.id 9 | WHERE n.headername='date'; 10 | 11 | 12 | -------------------------------------------------------------------------------- /sql/postgresql/2_3_4-2_3_5.pgsql: -------------------------------------------------------------------------------- 1 | begin; 2 | ALTER TABLE dbmail_mailboxes ADD seq BIGINT DEFAULT 0; 3 | CREATE INDEX dbmail_mailboxes_seq ON dbmail_mailboxes(seq); 4 | ALTER TABLE dbmail_mailboxes DROP mtime; 5 | alter table dbmail_users add p2 varchar(130) not null default ''; 6 | update dbmail_users set p2=passwd; 7 | alter table dbmail_users drop passwd; 8 | alter table dbmail_users rename p2 to passwd; 9 | commit; 10 | 11 | -------------------------------------------------------------------------------- /sql/postgresql/3_0_2-3_1_0.psql: -------------------------------------------------------------------------------- 1 | 2 | DROP VIEW IF EXISTS dbmail_datefield; 3 | CREATE VIEW dbmail_datefield AS 4 | SELECT physmessage_id,datefield,sortfield 5 | FROM dbmail_messages m 6 | JOIN dbmail_header h USING (physmessage_id) 7 | JOIN dbmail_headername n ON h.headername_id = n.id 8 | JOIN dbmail_headervalue v ON h.headervalue_id = v.id 9 | WHERE n.headername='date'; 10 | 11 | 12 | -------------------------------------------------------------------------------- /test-scripts/testexpunge.imap: -------------------------------------------------------------------------------- 1 | 1 login testuser1 test 2 | 2 select INBOX 3 | 3 store 1,2 +flags.silent (\Deleted) 4 | 4 noop 5 | 5 expunge 6 | 6 fetch 1:* (uid) 7 | 7 store 1 +flags (\Deleted) 8 | 8 store 2 +flags (\Deleted) 9 | 9 expunge 10 | 10 fetch 1:* (uid) 11 | 11 store 1 +flags (\Deleted) 12 | 12 uid store * +flags (\Deleted) 13 | 13 uid expunge 14 | 13 uid expunge 1 15 | 13 uid expunge * 16 | 14 close 17 | 15 logout 18 | -------------------------------------------------------------------------------- /sql/postgresql/upgrades/32001.psql: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | 4 | CREATE TABLE dbmail_upgrade_steps ( 5 | from_version int not null, 6 | to_version int not null, 7 | applied TIMESTAMP WITHOUT TIME ZONE DEFAULT NOW() 8 | ); 9 | 10 | CREATE UNIQUE INDEX dbmail_upgrade_steps_index_1 ON dbmail_upgrade_steps (from_version, to_version); 11 | INSERT INTO dbmail_upgrade_steps (from_version, to_version) values (0, 32001); 12 | 13 | COMMIT; 14 | -------------------------------------------------------------------------------- /sql/sqlite/upgrades/32001.sqlite: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | 4 | CREATE TABLE dbmail_upgrade_steps ( 5 | from_version int not null, 6 | to_version int not null, 7 | applied datetime default current_timestamp not null 8 | ); 9 | 10 | CREATE UNIQUE INDEX dbmail_upgrade_steps_index_1 on dbmail_upgrade_steps(from_version, to_version); 11 | 12 | INSERT INTO dbmail_upgrade_steps (from_version, to_version) values (0, 32001); 13 | 14 | COMMIT; 15 | -------------------------------------------------------------------------------- /sql/postgresql/2_1_7-2_2_0.pgsql: -------------------------------------------------------------------------------- 1 | 2 | CREATE SEQUENCE dbmail_envelope_idnr_seq; 3 | CREATE TABLE dbmail_envelope ( 4 | physmessage_id INT8 NOT NULL 5 | REFERENCES dbmail_physmessage(id) 6 | ON UPDATE CASCADE ON DELETE CASCADE, 7 | id INT8 DEFAULT nextval('dbmail_envelope_idnr_seq'), 8 | envelope TEXT NOT NULL DEFAULT '', 9 | PRIMARY KEY (id) 10 | ); 11 | CREATE UNIQUE INDEX dbmail_envelope_1 ON dbmail_envelope(physmessage_id, id); 12 | 13 | 14 | -------------------------------------------------------------------------------- /man/dbmail.conf.txt: -------------------------------------------------------------------------------- 1 | DBMAIL.CONF(5) 2 | ============== 3 | Author 4 | 5 | NAME 6 | ---- 7 | dbmail.conf - configuration file for DBMail, the Database Mailer. 8 | 9 | SYNOPSIS 10 | -------- 11 | There are 8 sections: DBMAIL, SMTP, LMTP, POP, IMAP, SIEVE, LDAP, DELIVERY. 12 | The default config file already has documentation for all of the settings. 13 | 14 | DESCRIPTION 15 | ----------- 16 | 17 | sys::[sed "s/^/ /" ../dbmail.conf] 18 | 19 | 20 | include::footer.txt[] 21 | -------------------------------------------------------------------------------- /test-scripts/imap/uidplus: -------------------------------------------------------------------------------- 1 | capabilities: UIDPLUS 2 | state: created 3 | 4 | ok select ${mailbox} 5 | ok append 6 | 7 | "" delete ${mailbox}2 8 | ok create ${mailbox}2 9 | 10 | append ${mailbox}2 11 | ok [appenduid $uidvalidity $uid] 12 | 13 | copy 1 ${mailbox}2 14 | ok [copyuid $uidvalidity $srcuid $uid2] 15 | 16 | ok select ${mailbox}2 17 | * ok [uidvalidity $uidvalidity] 18 | ok fetch 1:2 uid 19 | * 1 fetch (uid $uid) 20 | * 2 fetch (uid $uid2) 21 | 22 | ok close 23 | "" delete ${mailbox}2 24 | -------------------------------------------------------------------------------- /man/dbmail-httpd.txt: -------------------------------------------------------------------------------- 1 | DBMAIL-HTTPD(8) 2 | =============== 3 | 4 | 5 | NAME 6 | ---- 7 | dbmail-httpd - speaks the HTTP-1.1 protocol 8 | 9 | SYNOPSIS 10 | -------- 11 | dbmail-httpd [-f configfile] [-p pidfile] [-nvVh] 12 | 13 | DESCRIPTION 14 | ----------- 15 | Exposes DBMail's datamodel through a REST-full api. 16 | 17 | Please refer to contrib/dbmailclient.php for supported 18 | url paths. 19 | 20 | include::serveropts.txt[] 21 | 22 | include::commonopts.txt[] 23 | 24 | include::footer.txt[] 25 | -------------------------------------------------------------------------------- /man/dbmail-pop3d.txt: -------------------------------------------------------------------------------- 1 | DBMAIL-POP3D(8) 2 | =============== 3 | 4 | 5 | NAME 6 | ---- 7 | dbmail-pop3d - provides access to the DBMail system to client support- 8 | ing Post Office Protocol, POP3, as specified in RFC 1939. 9 | 10 | SYNOPSIS 11 | -------- 12 | dbmail-pop3d [-f configfile] [-p pidfile] [-nvVh] 13 | 14 | DESCRIPTION 15 | ----------- 16 | The dbmail-pop3d daemon is a fully featured POP3 server. 17 | 18 | 19 | include::serveropts.txt[] 20 | 21 | include::commonopts.txt[] 22 | 23 | include::footer.txt[] 24 | -------------------------------------------------------------------------------- /test-scripts/testsieve.txt: -------------------------------------------------------------------------------- 1 | CAPABILITY 2 | AUTHENTICATE "PLAIN" "cHJveHkAdGVzdHVzZXIxAHRlc3Q=" 3 | HAVESPACE "myscript" 999999 4 | HAVESPACE "myscript" 1000 5 | PUTSCRIPT "myscript" {163+} 6 | require ["fileinto"]; 7 | 8 | if envelope :contains "to" "tmartin+sent" { 9 | fileinto "INBOX.sent"; 10 | } 11 | if header :contains ["Subject"] ["test","ć"] { 12 | fileinto "test"; 13 | } 14 | LISTSCRIPTS 15 | SETACTIVE "myscript" 16 | SETACTIVE "" 17 | SETACTIVE "nosuchscript" 18 | GETSCRIPT "myscript" 19 | DELETESCRIPT "myscript" 20 | LOGOUT 21 | -------------------------------------------------------------------------------- /sql/sqlite/upgrades/32002.sqlite: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | DROP VIEW IF EXISTS dbmail_subjectfield; 4 | CREATE VIEW dbmail_subjectfield AS 5 | SELECT physmessage_id, headervalue AS subjectfield, sortfield 6 | FROM dbmail_messages m 7 | JOIN dbmail_header h USING (physmessage_id) 8 | JOIN dbmail_headername n ON h.headername_id = n.id 9 | JOIN dbmail_headervalue v ON h.headervalue_id = v.id 10 | WHERE n.headername = 'subject'; 11 | 12 | INSERT INTO dbmail_upgrade_steps (from_version, to_version) values (32001, 32002); 13 | COMMIT; 14 | 15 | -------------------------------------------------------------------------------- /debian/pgsql2mysql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # example script to convert from postgresql to mysql 4 | # 5 | # This file is not a part of the original dbmail package. 6 | # 7 | # It's slow, but it works. 8 | # 9 | # $Id$ 10 | 11 | mysqladmin -f drop dbmail 12 | mysqladmin create dbmail 13 | zcat /usr/share/doc/dbmail-mysql/examples/create_tables_innoDB.mysql.gz | mysql dbmail 14 | pg_dump --file=/var/tmp/dbmail-dump.pgdata --format=p --data-only --inserts --no-owner --no-reconnect --no-privileges dbmail 15 | mysql -f dbmail < /var/tmp/dbmail-dump.pgdata 16 | -------------------------------------------------------------------------------- /sql/mysql/update_headervalue_01.mysql: -------------------------------------------------------------------------------- 1 | 2 | 3 | # changes the storagetype of dbmail_headervalue.headervalue to TEXT 4 | 5 | # only apply this when dbmail_headervalue.headervalue is VARCHAR(255); 6 | 7 | alter table dbmail_headervalue drop index physmessage_id_2; 8 | 9 | alter table dbmail_headervalue change headervalue headervalue text not null; 10 | 11 | alter table dbmail_headervalue add unique index physmessage_id_2 (physmessage_id, headername_id, headervalue(255)); 12 | alter table dbmail_headervalue add index (headervalue(255)); 13 | 14 | 15 | -------------------------------------------------------------------------------- /man/dbmail-timsieved.txt: -------------------------------------------------------------------------------- 1 | DBMAIL-TIMSIEVED(8) 2 | =================== 3 | 4 | 5 | NAME 6 | ---- 7 | dbmail-timsieved - speaks the Manage Sieve draft protocol, used for managing 8 | Sieve scripts for a user's email account. 9 | 10 | SYNOPSIS 11 | -------- 12 | dbmail-timsieved [-f configfile] [-p pidfile] [-nvVh] 13 | 14 | DESCRIPTION 15 | ----------- 16 | The dbmail-timsieved process listens, by default, on port 2000 17 | of the localhost interface. 18 | 19 | include::serveropts.txt[] 20 | 21 | include::commonopts.txt[] 22 | 23 | include::footer.txt[] 24 | -------------------------------------------------------------------------------- /sql/mysql/upgrades/32002.mysql: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | DROP VIEW IF EXISTS dbmail_subjectfield; 4 | CREATE VIEW dbmail_subjectfield AS 5 | SELECT physmessage_id, headervalue AS subjectfield, sortfield 6 | FROM dbmail_messages m 7 | JOIN dbmail_header h USING (physmessage_id) 8 | JOIN dbmail_headername n ON h.headername_id = n.id 9 | JOIN dbmail_headervalue v ON h.headervalue_id = v.id 10 | WHERE n.headername = 'subject'; 11 | 12 | INSERT INTO dbmail_upgrade_steps (from_version, to_version, applied) values (32001, 32002, now()); 13 | COMMIT; 14 | 15 | -------------------------------------------------------------------------------- /sql/postgresql/upgrades/32002.psql: -------------------------------------------------------------------------------- 1 | 2 | BEGIN; 3 | DROP VIEW IF EXISTS dbmail_subjectfield; 4 | CREATE VIEW dbmail_subjectfield AS 5 | SELECT physmessage_id, headervalue AS subjectfield, sortfield 6 | FROM dbmail_messages m 7 | JOIN dbmail_header h USING (physmessage_id) 8 | JOIN dbmail_headername n ON h.headername_id = n.id 9 | JOIN dbmail_headervalue v ON h.headervalue_id = v.id 10 | WHERE n.headername::text = 'subject'::text; 11 | 12 | INSERT INTO dbmail_upgrade_steps (from_version, to_version) values (32001, 32002); 13 | COMMIT; 14 | 15 | -------------------------------------------------------------------------------- /contrib/sql2sql/pgsql2mysql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # example script to convert from postgresql to mysql 4 | # 5 | # It's slow, but it works. 6 | # 7 | 8 | PGDB="dbmail" 9 | MYDB="dbmail" 10 | 11 | TMPDIR="/var/tmp" 12 | 13 | mysqladmin drop $MYDB 14 | mysqladmin create $MYDB 15 | zcat /usr/share/doc/dbmail-mysql/examples/create_tables_innoDB.mysql.gz | mysql $MYDB 16 | pg_dump --file=$TMPDIR/dbmail-dump.pgdata \ 17 | --format=p --data-only --inserts \ 18 | --no-owner --no-reconnect --no-privileges $PGDB 19 | 20 | mysql -f $MYDB < $TMPDIR/dbmail-dump.pgdata 21 | 22 | -------------------------------------------------------------------------------- /debian/dbmail.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ -f /usr/share/debconf/confmodule ]; then 6 | . /usr/share/debconf/confmodule 7 | fi 8 | 9 | 10 | if [ "$1" = "purge" ]; then 11 | 12 | rm -f /etc/dbmail/dbmail.conf || true 13 | rm -f /etc/default/dbmail || true 14 | 15 | rmdir /etc/dbmail >/dev/null || true 16 | 17 | ucf --purge /etc/dbmail/dbmail.conf || true 18 | ucf --purge /etc/default/dbmail || true 19 | 20 | userdel dbmail 2>&1 > /dev/null || true 21 | 22 | db_purge || true 23 | fi 24 | 25 | #DEBHELPER# 26 | 27 | exit 0 28 | -------------------------------------------------------------------------------- /sql/mysql/3_0_2-3_1_0.mysql: -------------------------------------------------------------------------------- 1 | 2 | DROP VIEW IF EXISTS dbmail_datefield; 3 | CREATE VIEW dbmail_datefield AS 4 | SELECT physmessage_id,datefield,sortfield 5 | FROM dbmail_messages m 6 | JOIN dbmail_header h USING (physmessage_id) 7 | JOIN dbmail_headername n ON h.headername_id = n.id 8 | JOIN dbmail_headervalue v ON h.headervalue_id = v.id 9 | WHERE n.headername='date'; 10 | 11 | -------------------------------------------------------------------------------- /test-scripts/testsort.imap: -------------------------------------------------------------------------------- 1 | a01 login testuser1 test 2 | a02 select inbox 3 | a03 SORT (ARRIVAL FROM) US-ASCII 1,* 4 | a04 SORT (ARRIVAL FROM) US-ASCII UID 1,* 5 | a05 UID SORT (ARRIVAL FROM) US-ASCII UID 1,* 6 | a06 SORT (REVERSE ARRIVAL FROM) US-ASCII 1:* 7 | a07 SORT (REVERSE ARRIVAL FROM) US-ASCII UID 1:* 8 | a08 SORT (ARRIVAL FROM) US-ASCII ALL 9 | a09 UID SORT (ARRIVAL FROM) US-ASCII ALL 10 | a10 UID SORT (REVERSE ARRIVAL FROM) US-ASCII ALL 11 | a11 UID SORT (REVERSE ARRIVAL FROM) US-ASCII SUBJECT "some test" 12 | a12 SORT (REVERSE DATE) utf-8 SUBJECT "lars hase" 13 | a13 UID SORT 1:* (TO) UTF-8 ALL 14 | -------------------------------------------------------------------------------- /sql/oracle/dbmail_ts.sql: -------------------------------------------------------------------------------- 1 | -- DESCRIPTION 2 | -- Simple example script to create tablespaces 3 | -- usage: 4 | -- sqlplus "/ as sysdba" @create_ts.sql DATA_TOP 5 | 6 | SPOOL "create_ts.log" 7 | 8 | create tablespace DBMAIL_TS_DATA 9 | datafile '&1/dbmail_ts_data01.dbf' 10 | size 400M 11 | autoextend on 12 | next 100M maxsize 4000M 13 | extent management local 14 | uniform size 1M; 15 | 16 | create tablespace DBMAIL_TS_IDX 17 | datafile '&1/dbmail_ts_idx0i1.dbf' 18 | size 400M 19 | autoextend on 20 | next 100M maxsize 4000M 21 | extent management local 22 | uniform size 1M; 23 | 24 | SPOOL OFF 25 | EXIT; 26 | 27 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by Paul J Stevens on 2 | Tue, 15 Oct 2002 10:39:19 +0200. 3 | 4 | It was downloaded from http://www.dbmail.org 5 | 6 | Copyright (C) 1999-2004 IC & S, dbmail@ic-s.nl 7 | Copyright (C) 2001-2006 Aaron Stone, aaron@serendipity.cx 8 | Copyright (C) 2004-2006 NFG Net Facilities Group BV, support@nfg.nl 9 | 10 | Authors: DBmail Development Team 11 | 12 | This code is released under the terms of the GNU GENERAL PUBLIC LICENSE. 13 | On Debian GNU/Linux systems, the text of the GPL can be found in 14 | /usr/share/common-licenses/GPL. 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /debian/default.dbmail: -------------------------------------------------------------------------------- 1 | # debian specific configuration for dbmail 2 | 3 | # work-around for linux/epoll bug in libevent 4 | export EVENT_NOEPOLL=yes 5 | 6 | # comment out to disable the pop3 server 7 | #START_POP3D=true 8 | 9 | # comment out to disable the imapd server 10 | #START_IMAPD=true 11 | 12 | # uncomment to enable the lmtpd server 13 | #START_LMTPD=true 14 | 15 | # uncomment to enable the timsieved server 16 | #START_SIEVE=true 17 | 18 | # comment out to enable the stunnel SSL wrapper 19 | #START_SSL=true 20 | 21 | # specify the filename for the pem file as 22 | # it resides in /etc/ssl/certs 23 | #PEMFILE="dbmail.pem" 24 | -------------------------------------------------------------------------------- /man/dbmail-lmtpd.txt: -------------------------------------------------------------------------------- 1 | DBMAIL-LMTPD(8) 2 | =============== 3 | 4 | 5 | NAME 6 | ---- 7 | dbmail-lmtpd - receive messages from an MTA supporting the Lightweight 8 | Mail Transport Protocol, as specified in RFC 2033. 9 | 10 | SYNOPSIS 11 | -------- 12 | dbmail-lmtpd [-f configfile] [-p pidfile] [-nvVh] 13 | 14 | DESCRIPTION 15 | ----------- 16 | Mail Transfer Agents, MTA's such as Postfix and Exim, speak LMTP to 17 | their Mail Delivery Agents which receive and store messages. DBMail 18 | implements such a system using a database backend. 19 | 20 | include::serveropts.txt[] 21 | 22 | include::commonopts.txt[] 23 | 24 | include::footer.txt[] 25 | -------------------------------------------------------------------------------- /test-scripts/imap/fetch-body.mbox: -------------------------------------------------------------------------------- 1 | From user@domain Fri Feb 22 17:06:23 2008 2 | From: User1 3 | Date: Sat, 24 Mar 2007 23:00:00 +0200 4 | Subject: s1 5 | 6 | body1 7 | 8 | From user@domain Fri Feb 22 17:06:23 2008 9 | From: User2 10 | Date: Sat, 24 Mar 2007 23:00:00 +0200 11 | Subject: s22 12 | 13 | body22 14 | 15 | From user@domain Fri Feb 22 17:06:23 2008 16 | From: User3 17 | Date: Sat, 24 Mar 2007 23:00:00 +0200 18 | Subject: s333 19 | 20 | body33 21 | 22 | From user@domain Fri Feb 22 17:06:23 2008 23 | From: User4 24 | Date: Sat, 24 Mar 2007 23:00:00 +0200 25 | Subject: s4444 26 | 27 | body4444 28 | 29 | -------------------------------------------------------------------------------- /test-scripts/testlmtp2.txt: -------------------------------------------------------------------------------- 1 | LHLO host 2 | MAIL FROM: <> 3 | RCPT TO: 4 | RCPT TO: 5 | DATA 6 | To: user@dom 7 | Subject: =?ISO-8859-2?Q?E-mail=20noviny=2016/06:=20Vli?= 8 | =?ISO-8859-2?Q?v=20p=F8=EDjm=F9=20ze=20zam=ECstn=E1n=ED=20n?= 9 | =?ISO-8859-2?Q?a=20z=E1lohy=20fyzick=FDch=20osob?= 10 | Sender: =?ISO-8859-2?Q? "Verlag=20Dash=F6fer=20-=20DU.cz?= 11 | =?ISO-8859-2?Q?" 12 | ?= 13 | Reply-To: =?ISO-8859-2?Q?Verlag=20Dash=F6fer=20?= 14 | From: =?ISO-8859-2?Q? "Verlag=20Dash=F6fer=20-=20DU.cz?= =?ISO-8859-2?Q?" 15 | ?= 16 | " 21 | 22 | -------------------------------------------------------------------------------- /m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3337 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.2' 20 | macro_revision='1.3337' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /test-scripts/imap/select: -------------------------------------------------------------------------------- 1 | state: created 2 | 3 | ok append 4 | ok append 5 | 6 | # first open read-only so recent flags don't get lost 7 | examine $mailbox 8 | * 2 exists 9 | * 2 recent 10 | * ok [unseen 1] 11 | * ok [uidvalidity $uidvalidity] 12 | * ok [uidnext $uidnext] 13 | ok [read-only] 14 | 15 | ok close 16 | 17 | # check that STATUS replies with the same values 18 | ok status $mailbox (messages recent uidnext uidvalidity unseen) 19 | * status $mailbox (messages 2 recent 2 uidnext $uidnext uidvalidity $uidvalidity unseen 2) 20 | 21 | # then try read-write 22 | select $mailbox 23 | * 2 exists 24 | * 2 recent 25 | * ok [unseen 1] 26 | * ok [uidvalidity $uidvalidity] 27 | * ok [uidnext $uidnext] 28 | ok [read-write] 29 | 30 | ok close 31 | 32 | ok status $mailbox (recent) 33 | * status $mailbox (recent 0) 34 | -------------------------------------------------------------------------------- /test-scripts/testcondstore.txt: -------------------------------------------------------------------------------- 1 | x login testuser1 test 2 | x examine inbox (condstore) 3 | x select inbox (condstore) 4 | x store 1 +flags \Flagged 5 | x store 1 -flags \Flagged (UNCHANGEDSINCE 1) 6 | x uid store * +flags ($test) (UNCHANGEDSINCE 1) 7 | x uid store * +flags.silent ($test) (UNCHANGEDSINCE 1) 8 | x uid store * +flags.silent ($test) (UNCHANGEDSINCE 0) 9 | x noop 10 | x fetch * flags modseq 11 | x uid fetch * flags modseq 12 | x fetch * flags (changedsince 1) 13 | x uid fetch * flags (changedsince 1) 14 | x UID fetch * (FLAGS) (CHANGEDSINCE 0) 15 | x fetch * flags (changedsince 99999999999) 16 | x uid search modseq "/flags/\\draft" all 1 17 | x uid search modseq "/flags/\\draft" all 1 18 | x uid search modseq "/flags/\\draft" all 9999999999 19 | x uid search modseq 1 20 | x uid search modseq 9999999999 21 | x logout 22 | -------------------------------------------------------------------------------- /test-scripts/imap/store: -------------------------------------------------------------------------------- 1 | connections: 2 2 | 3 | # simple tests 4 | 1 ok store 1:3 flags (\seen) 5 | * 1 fetch (flags (\seen)) 6 | * 2 fetch (flags (\seen)) 7 | * 3 fetch (flags (\seen)) 8 | 9 | 2 ok check 10 | * 1 fetch (flags (\seen)) 11 | * 2 fetch (flags (\seen)) 12 | * 3 fetch (flags (\seen)) 13 | 14 | 1 ok store 4 -flags \seen 15 | 1 ok store 3 flags (\draft) 16 | * 3 fetch (flags (\draft)) 17 | 18 | # keywords 19 | 1 ok store 2,4 +flags ($$hello $$world) 20 | * 2 fetch (flags (\seen $$hello $$world)) 21 | * 4 fetch (flags ($$hello $$world)) 22 | 23 | # check that two sessions don't overwrite each others' changes 24 | 1 ok store 1 +flags (\answered) 25 | 2 ok store 1 -flags (\seen) 26 | 1 ok check 27 | 2 ok check 28 | 29 | 1 ok fetch 1 flags 30 | * 1 fetch (flags (\answered)) 31 | 2 ok fetch 1 flags 32 | * 1 fetch (flags (\answered)) 33 | -------------------------------------------------------------------------------- /test-scripts/imap/mutf7: -------------------------------------------------------------------------------- 1 | state: auth 2 | 3 | # get the separator 4 | ok list "" "" 5 | * list () $sep $root 6 | 7 | ok create "$mailbox${sep}&BBoEOARXBDI-" 8 | ok create "$mailbox${sep}&BBoEOARXBDI-${sep}&BBwEMAQ5BDQEMAQ9-" 9 | ok create "$mailbox${sep}&BBoEOARXBDI-${sep}&BBcEPgQ7BD4EQgRW-" 10 | ok create "$mailbox${sep}&BBoEOARXBDI-${sep}&BBIEPgRABD4EQgQw-" 11 | 12 | ok list "" "$mailbox${sep}&BBoEOARXBDI-" 13 | * list () $sep "$mailbox${sep}&BBoEOARXBDI-" 14 | 15 | ok list "" "${mailbox}${sep}&BBoEOARXBDI-${sep}%" 16 | * list () $sep "$mailbox${sep}&BBoEOARXBDI-${sep}&BBwEMAQ5BDQEMAQ9-" 17 | * list () $sep "$mailbox${sep}&BBoEOARXBDI-${sep}&BBcEPgQ7BD4EQgRW-" 18 | * list () $sep "$mailbox${sep}&BBoEOARXBDI-${sep}&BBIEPgRABD4EQgQw-" 19 | 20 | ok status "$mailbox${sep}&BBoEOARXBDI-" (messages) 21 | * status "$mailbox${sep}&BBoEOARXBDI-" (messages 0) 22 | 23 | 24 | -------------------------------------------------------------------------------- /test-scripts/testfetch.imap: -------------------------------------------------------------------------------- 1 | x CAPABILITY 2 | x LOGIN testuser1 test 3 | x NAMESPACE 4 | x LIST "" "*" 5 | x LSUB "" "*" 6 | x SELECT INBOX 7 | x fetch 1 (UID BODY.PEEK[HEADER]) 8 | x APPEND INBOX {11} 9 | From: paul 10 | x UID FETCH 1:* (FLAGS RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (DATE FROM TO CC SUBJECT REFERENCES IN-REPLY-TO MESSAGE-ID MIME-VERSION CONTENT-TYPE X-MAILING-LIST X-LOOP LIST-ID LIST-POST MAILING-LIST ORIGINATOR X-LIST SENDER RETURN-PATH X-BEENTHERE)]) 11 | x UID FETCH 1:* (BODY.PEEK[HEADER.FIELDS (References X-Ref X-Priority X-MSMail-Priority X-MSOESRec Newsgroups)] ENVELOPE RFC822.SIZE UID FLAGS INTERNALDATE) 12 | x UID FETCH 1:* (BODY.PEEK[HEADER.FIELDS (Subject)] BODY.PEEK[HEADER.FIELDS (Message-Id)] ENVELOPE RFC822.SIZE UID FLAGS INTERNALDATE) 13 | x UID FETCH 1:* (UID RFC822.SIZE BODY.PEEK[]) 14 | x FETCH 1:* RFC822.TEXT 15 | x LOGOUT 16 | -------------------------------------------------------------------------------- /debian/README.Debian: -------------------------------------------------------------------------------- 1 | 2 | dbmail for Debian 3 | 4 | 5 | ----------------- 6 | 7 | Before you can run dbmail you will have to create the database, 8 | create the required tables and grant access to the user specified 9 | in dbmail.conf. 10 | 11 | If you are upgrading from dbmail-1.2 you will find that the sql tables 12 | have changed and are incompatible with dbmail-2.x. Migration scripts 13 | for your database backend are provided in the examples directory. None 14 | of the dbmail-2 binaries will run until you have upgraded your database. 15 | 16 | The debian package runs dbmail-deliver as user dbmail via suid. 17 | This will allow normal users to insert mail through dbmail-deliver 18 | (i.e. from procmail) without granting them access to dbmail.conf 19 | and the password contained therein. 20 | 21 | --- 22 | Paul Stevens 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /test-scripts/dumpbt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # generate a backtrace for busy worker threads 4 | PNAME=${1:-dbmail-imapd} 5 | 6 | # only look for thread with more that MAXCPU cpu load 7 | MAXCPU=${2:-20} 8 | 9 | # get the imap PID 10 | PID=`pidof $PNAME` 11 | 12 | [ -n "$PID" ] || { echo "Error: Unable to determine main process ID for $PNAME"; exit 1; } 13 | 14 | echo "generate backtrace for $PNAME($PID) with CPU > $MAXCPU" 15 | 16 | # find busy threads 17 | BUSY=`top -H -b -n1 -p $PID|grep -E "${PNAME}|pool"| awk '{if ($9 > $MAXCPU) print $1}'` 18 | 19 | [ -n "$BUSY" ] || exit 0 20 | 21 | # generate a gdb commandfile 22 | tmpfile=`mktemp` 23 | echo 'bt' > $tmpfile 24 | for TID in $BUSY; do 25 | # get a backtrace 26 | gdb --batch -x $tmpfile -p $TID > \ 27 | /tmp/debug-dbmail-backtrace.$TID 28 | echo "backtrace for $PNAME in " /tmp/debug-dbmail-backtrace.$TID 29 | done 30 | rm -f $tmpfile 31 | 32 | -------------------------------------------------------------------------------- /man/footer.txt: -------------------------------------------------------------------------------- 1 | 2 | BUGS 3 | ---- 4 | If you experience inexplicable problems with DBMail, please report the issue 5 | to the http://dbmail.org/mantis/[DBMail Bug Tracker]. 6 | 7 | LICENSE 8 | ------- 9 | DBMail and its components are distributed under the terms of the GNU General 10 | Public License. Copyrights are held variously by the authors listed below. 11 | 12 | AUTHOR(S) 13 | --------- 14 | DBMail is a collaborative effort among the core developers listed below and 15 | the tremendous help of the testers, patchers and bug hunters listed in the 16 | AUTHORS and THANKS files found in the DBMail source distribution. 17 | 18 | Eelco van Beek Aaron Stone Paul J Stevens 19 | Roel Rozendaal Open Source Engineer NFG Net Facilities Group BV 20 | Ilja Booij Palo Alto, CA USA http://www.nfg.nl 21 | IC&S http://hydricacid.com 22 | http://www.ic-s.nl 23 | 24 | -------------------------------------------------------------------------------- /doc/README.exim: -------------------------------------------------------------------------------- 1 | 2 | 3 | Using DBMail with Exim4 4 | by Thomas Mueller 5 | ======================= 6 | 7 | 1. Prerequisites 8 | 9 | * A Exim installation 10 | * A DBMail installation 11 | 12 | 2. Generic 13 | 14 | LOCAL_DELIVERY=transport_dbmail 15 | 16 | Every router with local mail has to use 'transport = LOCAL_DELIVERY' then. 17 | 18 | 3. dbmail-deliver 19 | 20 | # transport using pipe 21 | transport_dbmail: 22 | driver = pipe 23 | command = "/usr/local/sbin/dbmail-deliver -d $local_part@$domain" 24 | return_fail_output 25 | user = dbmail 26 | 27 | 3. dbmail-lmtp 28 | 29 | # transport using lmtp; exim and dbmail on the same host 30 | transport_dbmail: 31 | driver = smtp 32 | protocol = lmtp 33 | hosts = localhost 34 | allow_localhost 35 | return_path_add 36 | 37 | LMTP requires lmtp entries in /etc/services (they are not there in Debian!). 38 | 39 | lmtp 24/tcp 40 | lmtp 24/udp 41 | 42 | 43 | -------------------------------------------------------------------------------- /test-scripts/imap/expunge2: -------------------------------------------------------------------------------- 1 | connections: 2 2 | 3 | 1 ok fetch 2,4 uid 4 | * 2 fetch (uid $uid2) 5 | * 4 fetch (uid $uid4) 6 | 7 | # UID FETCH 8 | 1 ok store 1,3 +flags \deleted 9 | 1 ok expunge 10 | * $1 expunge 11 | * $3 expunge 12 | 13 | 2 ok uid fetch $uid2,$uid4 uid 14 | * $2 fetch (uid $uid2) 15 | * $4 fetch (uid $uid4) 16 | 2 ok noop 17 | 18 | # UID STORE 19 | 1 ok store 1 +flags \deleted 20 | 1 ok expunge 21 | * 1 expunge 22 | 23 | 2 ok uid store $uid4 flags \seen 24 | * $2 fetch (uid $uid4 flags (\seen)) 25 | 2 ok noop 26 | 27 | # Make sure CHECK works just as well as NOOP 28 | 1 ok store 1 +flags \deleted 29 | 1 ok expunge 30 | * 1 expunge 31 | 2 ok check 32 | * 1 expunge 33 | 34 | # Make sure FETCH, STORE and SEARCH don't trigger EXPUNGE 35 | 1 ok store 1 +flags \deleted 36 | 1 ok expunge 37 | 38 | 2 ok fetch 2 flags 39 | ! $1 expunge 40 | 2 ok store 2 flags (\seen) 41 | ! $1 expunge 42 | 2 ok search all 43 | ! $1 expunge 44 | -------------------------------------------------------------------------------- /test-scripts/imap/search-header: -------------------------------------------------------------------------------- 1 | 2 | # just check that this returns ok. it's not really specified in RFC, so 3 | # don't verify the result. 4 | ok search subject "" 5 | 6 | # subject 7 | ok search subject hello 8 | * search 1 9 | ok search subject beautiful 10 | * search 1 11 | ok search subject world 12 | * search 1 13 | ok search subject "hello beautiful" 14 | * search 1 15 | ok search subject "hello beautiful world" 16 | * search 1 17 | ok search subject "eautiful worl" 18 | * search 1 19 | 20 | # header 21 | ok search header subject "" 22 | * search 1 23 | ok search not header subject "" 24 | * search 2 25 | ok search header x-extra "" 26 | * search 2 27 | ok search not header x-extra "" 28 | * search 1 29 | ok search header x-extra hello 30 | * search 2 31 | ok search header x-extra "hello beautiful" 32 | * search 2 33 | ok search header x-extra "eautiful head" 34 | * search 2 35 | ok search header x-extra "another" 36 | * search 2 37 | -------------------------------------------------------------------------------- /contrib/mailbox2dbmail/mailbox2dbmail.yo: -------------------------------------------------------------------------------- 1 | manpage(mailbox2dbmail)(1)(2004-03-07)(MirrorLynx)(Debian Distribution) 2 | manpagename(mailbox2dbmail)(Tool to move your flat filesystem mailboxen to dbmail mailboxen) 3 | manpagesynopsis() 4 | mailbox2dbmail [OPTIONS] 5 | manpageoptions() 6 | startdit() 7 | dit(bf(-v,--version)) Version info 8 | dit(bf(-h,--help)) Help Display 9 | dit(bf(-b,--box)) IMAP folder to stick mail in under user (default: Inbox) 10 | dit(bf(-m,--mail)) Location of Mailbox (required) 11 | dit(bf(-u,--user)) Username (required) 12 | dit(bf(-t,--type)) Type of Mailbox: mbox, maildir, mhdir (required) 13 | dit(bf(-p,--path)) Path to dbmail-deliver (default: /usr/sbin/dbmail-deliver) 14 | enddit() 15 | 16 | manpageseealso() 17 | bf(python(1)), and bf(pydoc mailbox) 18 | 19 | manpagebugs() 20 | Contact nemail(Dan Weber)(dan@mirrorlynx.com), for any bugs with this program. 21 | 22 | manpageauthor() 23 | This manpage was written by nemail(Dan Weber)(dan@mirrorlynx.com), 2004 24 | -------------------------------------------------------------------------------- /src/sortmodule.h: -------------------------------------------------------------------------------- 1 | /* Dynamic loading of the database backend. 2 | * We use GLib's multiplatform dl() wrapper 3 | * to open up sort_sieve.so and 4 | * populate the global 'sort' structure. 5 | * 6 | * (c) 2005 Aaron Stone 7 | */ 8 | 9 | #ifndef DM_SORTMODULE_H 10 | #define DM_SORTMODULE_H 11 | 12 | /* Prototypes must match with those in sort.h 13 | * and in the sorting drivers. */ 14 | typedef struct { 15 | SortResult_T *(* process)(uint64_t user_idnr, DbmailMessage *message, const char *mailbox); 16 | SortResult_T *(* validate)(uint64_t user_idnr, char *scriptname); 17 | void (* free_result)(SortResult_T *result); 18 | const char *(* listextensions)(void); 19 | int (* get_cancelkeep)(SortResult_T *result); 20 | int (* get_reject)(SortResult_T *result); 21 | const char *(* get_mailbox)(SortResult_T *result); 22 | const char *(* get_errormsg)(SortResult_T *result); 23 | int (* get_error)(SortResult_T *result); 24 | } sort_func; 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /test-scripts/imap/default.mbox: -------------------------------------------------------------------------------- 1 | From user@domain Fri Feb 22 17:06:23 2008 2 | From: user1@domain.org 3 | Date: Sat, 24 Mar 2007 23:00:00 +0200 4 | Subject: s1 5 | 6 | body1 7 | 8 | From user@domain Fri Feb 22 17:06:23 2008 9 | From: user2@domain.org 10 | Date: Sat, 24 Mar 2007 23:00:00 +0200 11 | Subject: s22 12 | 13 | body22 14 | 15 | From user@domain Fri Feb 22 17:06:23 2008 16 | From: user3@domain.org 17 | Date: Sat, 24 Mar 2007 23:00:00 +0200 18 | Subject: s333 19 | 20 | body33 21 | 22 | From user@domain Fri Feb 22 17:06:23 2008 23 | From: user4@domain.org 24 | Date: Sat, 24 Mar 2007 23:00:00 +0200 25 | Subject: s4444 26 | 27 | body4444 28 | 29 | From user@domain Fri Feb 22 17:06:23 2008 30 | From: user5@domain.org 31 | Date: Sat, 24 Mar 2007 23:00:00 +0200 32 | Subject: s55555 33 | 34 | body55555 35 | 36 | From user@domain Fri Feb 22 17:06:23 2008 37 | From: user6@domain.org 38 | Date: Sat, 24 Mar 2007 23:00:00 +0200 39 | Subject: s666666 40 | 41 | body666666 42 | 43 | -------------------------------------------------------------------------------- /doc/README.smtp: -------------------------------------------------------------------------------- 1 | 2 | 3 | DBMail POP/IMAP before SMTP 4 | =========================== 5 | 6 | DBMail can optionally keep a database table of the last time and IP 7 | address of each successful POP or IMAP login. This way you can allow 8 | your users to use your SMTP as a relay for a brief time after they log 9 | into their email. 10 | 11 | The dbmail_pbsp table is now created by default; you simply need to 12 | enable one or both of the following entries in your dbmail.conf file, 13 | depending on which services you would like to use for SMTP relay access: 14 | 15 | [POP] 16 | POP_BEFORE_SMTP=yes # If yes, allows SMTP access from the host IP connecting by POP3. 17 | 18 | [IMAP] 19 | POP_BEFORE_SMTP=yes # If yes, allows SMTP access from the host IP connecting by IMAP. 20 | 21 | After that you'll have to configure your MTA to read out that table 22 | for allowing connections on those IP's. Please see the various 23 | INSTALL. files for MTA configuration details. 24 | 25 | -------------------------------------------------------------------------------- /contrib/mailbox2dbmail/mailbox2dbmail.1: -------------------------------------------------------------------------------- 1 | .TH "mailbox2dbmail" "1" "2004-03-07" "MirrorLynx" "Debian Distribution" 2 | .SH "NAME" 3 | mailbox2dbmail \- Tool to move your flat filesystem mailboxen to dbmail mailboxen 4 | .SH "SYNOPSIS" 5 | mailbox2dbmail [OPTIONS] 6 | .SH "OPTIONS" 7 | .IP "\fB-v,--version\fP" 8 | Version info 9 | .IP "\fB-h,--help\fP" 10 | Help Display 11 | .IP "\fB-b,--box\fP" 12 | IMAP folder to stick mail in under user (default: Inbox) 13 | .IP "\fB-m,--mail\fP" 14 | Location of Mailbox (required) 15 | .IP "\fB-u,--user\fP" 16 | Username (required) 17 | .IP "\fB-t,--type\fP" 18 | Type of Mailbox: mbox, maildir, mhdir (required) 19 | .IP "\fB-p,--path\fP" 20 | Path to dbmail-deliver (default: /usr/sbin/dbmail-deliver) 21 | .PP 22 | .SH "SEE ALSO" 23 | \fBpython(1)\fP, and \fBpydoc mailbox\fP 24 | .PP 25 | .SH "BUGS" 26 | Contact Dan Weber , for any bugs with this program\&. 27 | .PP 28 | .SH "AUTHOR" 29 | This manpage was written by Dan Weber , 2004 30 | -------------------------------------------------------------------------------- /contrib/sql2sql/mysql2pgsql.yml: -------------------------------------------------------------------------------- 1 | 2 | # if a socket is specified we will use that 3 | # if tcp is chosen you can use compression 4 | mysql: 5 | hostname: localhost 6 | port: 3306 7 | socket: /var/run/mysqld/mysqld.sock 8 | username: dbmail 9 | password: 10 | database: dbmail 11 | compress: false 12 | destination: 13 | # if file is given, output goes to file, else postgres 14 | file: 15 | postgres: 16 | hostname: localhost 17 | port: 5432 18 | username: dbmail 19 | password: 20 | database: dbmail 21 | 22 | # if tables is given, only the listed tables will be converted. leave empty to convert all tables. 23 | only_tables: 24 | - dbmail_mimeparts 25 | 26 | # if supress_data is true, only the schema definition will be exported/migrated, and not the data 27 | supress_data: false 28 | 29 | # if supress_ddl is true, only the data will be exported/imported, and not the schema 30 | supress_ddl: true 31 | 32 | # if force_truncate is true, forces a table truncate before table loading 33 | force_truncate: false 34 | -------------------------------------------------------------------------------- /man/commonopts.txt: -------------------------------------------------------------------------------- 1 | 2 | COMMON OPTIONS 3 | -------------- 4 | -f configfile:: 5 | Specify an alternate config file. The utilities are currently 6 | hardcoded to use /etc/dbmail.conf for their configs, and will 7 | halt if the config file cannot be found. Use the -f configfile 8 | option to specify your system's preferred config file location. 9 | Debian is patched to have /etc/dbmail/dbmail.conf as the default. 10 | 11 | -q:: 12 | Quietly skip interactive prompts and helpful status messages 13 | which would otherwise be printed to stdout. Use two -q's to 14 | silence errors which would otherwise be printed to stderr. 15 | 16 | -v:: 17 | Operate verbosely. Some of the utilities in the DBMail suite 18 | can take two -v's for extra verbosity. Those which don't understand 19 | this convention won't complain about having the extra -v 20 | and will simply operate at their normal verbosity. 21 | 22 | -V:: 23 | Show the version and copyright, then exit. 24 | 25 | -h:: 26 | Show a brief summary of options, then exit. 27 | 28 | -------------------------------------------------------------------------------- /man/serveropts.txt: -------------------------------------------------------------------------------- 1 | 2 | OPTIONS 3 | ------- 4 | 5 | -p pidfile:: 6 | Specify an alternate pid file. By default the daemons use dbmail-.pid 7 | for their pid files, saving them in the directory specified by the 8 | pid_directory entry in dbmail.conf or if that does not exist the value set by 9 | the configuration option --localstatedir, and will halt if the pid file 10 | cannot be written. Use the -p pidfile option to place the pid file in 11 | your system's preferred location. 12 | 13 | -n:: 14 | No daemonize: inetd mode. The program remains attached to the console from 15 | which it was started and will read and write on stdin/stdout. This is quite 16 | useful for debugging when combined with the -v option. It is also used for 17 | running from (x)inetd. 18 | 19 | -D:: 20 | No daemonize: init mode. The program remains attached to the console and will 21 | listen on the network sockets defined in dbmail.conf. This is mostly used 22 | when running from inittab or under the control of daemontools. 23 | -------------------------------------------------------------------------------- /debian/dbmail.preinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | # summary of how this script can be called: 6 | # * `install' 7 | # * `install' 8 | # * `upgrade' 9 | # * `abort-upgrade' 10 | 11 | case "$1" in 12 | install|upgrade) 13 | # creating dbmail group if he isn't already there 14 | getent group dbmail >/dev/null 2>&1 || \ 15 | addgroup --system dbmail >/dev/null 2>&1 || true 16 | 17 | # creating dbmail user if he isn't already there 18 | getent passwd dbmail >/dev/null 2>&1 || \ 19 | adduser \ 20 | --system \ 21 | --ingroup dbmail \ 22 | --home /dev/null \ 23 | --gecos "Dbmail SQL mailserver" \ 24 | --shell /bin/false \ 25 | dbmail >/dev/null 2>&1 || true 26 | ;; 27 | 28 | abort-upgrade) 29 | ;; 30 | 31 | *) 32 | echo "preinst called with unknown argument \`$1'" >&2 33 | exit 1 34 | ;; 35 | esac 36 | 37 | #DEBHELPER# 38 | 39 | exit 0 40 | 41 | -------------------------------------------------------------------------------- /doc/README.sieve: -------------------------------------------------------------------------------- 1 | 2 | 3 | DBMail-2 as of 2.1.4 supports the Sieve mail sorting language. The libSieve 4 | library is used to provide the core Sieve interpreter: http://libsieve.sf.net/ 5 | 6 | Users are allowed to store their own Sieve scripts in the DBMail database, 7 | and to set the active script that will run as each message is received for 8 | a given user. Scripts are managed using "Tim's Sieve Daemon" protocol, which 9 | was specified in the MANAGESIEVE draft standard, but has long since expired. 10 | DBMail's timsieved is compatible with the widely deployed Cyrus timsieved, 11 | and client programs compatible with Cyrus timsieved should work well. 12 | 13 | Scripts can also be managed using the command line tool dbmail-sievecmd, but 14 | this is recommended only to be used for administrative maintenance; such as 15 | clearing out old scripts from deleted users or testing new configurations. 16 | 17 | Many thanks to Kevin Baker for his generous development bounty which spurred 18 | completion of this feature. Thanks to Aaron Stone for finishing the code. 19 | 20 | -------------------------------------------------------------------------------- /src/dm_http.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Copyright (C) 2008-2012 NFG Net Facilities Group BV, support@nfg.nl 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | 22 | #ifndef DM_HTTP_H 23 | #define DM_HTTP_H 24 | 25 | #include "dm_request.h" 26 | 27 | void Http_getUsers(Request_T); 28 | void Http_getMailboxes(Request_T); 29 | void Http_getMessages(Request_T); 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /doc/README.solaris: -------------------------------------------------------------------------------- 1 | 2 | README.solaris 3 | 4 | 5 | 6 | DBMail is able to produce a very large amount of debugging output if 7 | requested. Some of this debug output naturally includes strings that 8 | turn out to be null pointers. Solaris's printf doesn't like null 9 | pointers, and neither does the replacement printf in Glib. So DBMail 10 | will crash a lot on Solaris until Glib becomes null-safe. Requests 11 | have been made to the upstream library maintainers to work this out. 12 | 13 | In the meantime, in order to run DBMail on Solaris without crashing, 14 | you must add the following lines to your DBMail startup script: 15 | 16 | LD_PRELOAD_32=/usr/lib/0@0.so.1 17 | export LD_PRELOAD_32 18 | 19 | or if you've compiled DBMail as a 64-bit binary: 20 | 21 | LD_PRELOAD_64=/usr/lib/64/0@0.so.1 22 | export LD_PRELOAD_64 23 | 24 | We're really sorry about this, but rest assured that this is 25 | actually a good thing; without debugging calls that cause "(null)" 26 | to be printed, we'd have a much harder time tracking down errant null 27 | values in places where they don't belong! 28 | -------------------------------------------------------------------------------- /debian/dbmail.examples: -------------------------------------------------------------------------------- 1 | dbmail.conf 2 | dbmail.schema 3 | sql/mysql/2_1_7-2_2_0.mysql 4 | sql/mysql/2_2-3_0.mysql 5 | sql/mysql/2_2_5-2_3_0.mysql 6 | sql/mysql/2_3_0-2_3_2.mysql 7 | sql/mysql/2_3_4-2_3_5.mysql 8 | sql/mysql/2_3_5-2_3_6.mysql 9 | sql/mysql/2_3_6-3_0_0.mysql 10 | sql/mysql/create_tables.mysql 11 | sql/mysql/fix_foreign_keys.mysql 12 | sql/mysql/migrate_from_1.x_to_2.0_innodb.mysql 13 | sql/mysql/migrate_from_2.0_to_2.2.mysql 14 | sql/mysql/update_headervalue_01.mysql 15 | sql/postgresql/2_1_7-2_2_0.pgsql 16 | sql/postgresql/2_2-3_0.pgsql 17 | sql/postgresql/2_2_5-2_3_0.pgsql 18 | sql/postgresql/2_3_4-2_3_5.pgsql 19 | sql/postgresql/2_3_5-2_3_6.pgsql 20 | sql/postgresql/2_3_6-3_0_0.pgsql 21 | sql/postgresql/create_tables.pgsql 22 | sql/postgresql/migrate_from_1.x_to_2.0.pgsql 23 | sql/postgresql/migrate_from_2.0_to_2.2.pgsql 24 | sql/sqlite/2_1_7-2_2_0.sqlite 25 | sql/sqlite/2_2-3_0.sqlite 26 | sql/sqlite/2_2_5-2_3_0.sqlite 27 | sql/sqlite/2_3_4-2_3_5.sqlite 28 | sql/sqlite/2_3_5-2_3_6.sqlite 29 | sql/sqlite/2_3_6-3_0_0.sqlite 30 | sql/sqlite/create_tables.sqlite 31 | sql/sqlite/trigger.tmpl.sql 32 | -------------------------------------------------------------------------------- /src/dm_tls.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later 8 | version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #ifndef DM_TLS_H 21 | #define DM_TLS_H 22 | 23 | #include "dbmail.h" 24 | 25 | SSL_CTX *tls_init(void); 26 | SSL *tls_setup(int); 27 | void tls_load_certs(ServerConfig_T *); 28 | void tls_load_ciphers(ServerConfig_T *); 29 | char *tls_get_error(void); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: dbmail 2 | Section: mail 3 | Priority: optional 4 | Maintainer: Paul J Stevens 5 | Build-Depends: automake1.11, debhelper (>= 5.0.7), libncurses5-dev, libsieve2-dev (>= 2.1.12), libglib2.0-dev, libgmime-2.6-dev, libldap2-dev, libzdb-dev, libmhash-dev, libevent-dev, pkg-config, libtool, asciidoc, xmlto, po-debconf, libmysqlclient-dev | libmariadb-client-lgpl-dev, libpq-dev, libsqlite3-dev, libssl-dev 6 | Standards-Version: 3.9.1 7 | 8 | Package: dbmail 9 | Architecture: any 10 | Pre-Depends: adduser 11 | Depends: ${misc:Depends}, ${shlibs:Depends}, ucf (>= 0.30) 12 | Provides: imap-server, pop3-server 13 | Suggests: sqlite3 14 | Description: email storage server that supports SQL 15 | DBMail is a collection of programs that allow the use of a relational 16 | database to store both email messages and user account data. It 17 | supports Sieve filtering, and the client protocols POP3, IMAP4, LMTP, 18 | and ManageSieve. 19 | . 20 | This package supports LDAP authentication. Database backends are 21 | provided by libzdb which supports MySQL, PostgreSQL, SQLite and 22 | Oracle. 23 | . 24 | -------------------------------------------------------------------------------- /sql/oracle/dbmail_grant.sql: -------------------------------------------------------------------------------- 1 | -- DBMail db access control 2 | -- Call it under DBA user 3 | 4 | -- sqlplus log 5 | SPOOL "grant.log"; 6 | 7 | DROP USER dbmail CASCADE; 8 | CREATE USER dbmail IDENTIFIED BY dbmail 9 | DEFAULT TABLESPACE DBMAIL_TS_DATA 10 | TEMPORARY TABLESPACE TEMP 11 | ACCOUNT UNLOCK 12 | PROFILE porta_users; 13 | 14 | GRANT CREATE PROCEDURE, CREATE SEQUENCE, CREATE SESSION, CREATE TABLE, CREATE TRIGGER, CREATE SYNONYM, CREATE VIEW TO dbmail; 15 | ALTER USER dbmail QUOTA UNLIMITED ON DBMAIL_TS_DATA; 16 | ALTER USER dbmail QUOTA UNLIMITED ON DBMAIL_TS_IDX; 17 | 18 | CREATE OR REPLACE TRIGGER sys.db_user_nls_session_settings 19 | AFTER logon ON DBMAIL.SCHEMA 20 | BEGIN 21 | EXECUTE IMMEDIATE 'ALTER SESSION SET nls_date_format=''YYYY-MM-DD'''; 22 | EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TIMESTAMP_FORMAT=''YYYY-MM-DD HH24:MI:SS'''; 23 | EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT=''YYYY-MM-DD HH24:MI:SS'''; 24 | EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_COMP=''LINGUISTIC'''; 25 | EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_SORT=''BINARY_CI'''; 26 | END; 27 | / 28 | 29 | EXIT 30 | -------------------------------------------------------------------------------- /src/dm_cidr.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later 8 | version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | */ 20 | #ifndef DM_CIDR_H 21 | #define DM_CIDR_H 22 | /* 23 | * provide some CIDR utilities. 24 | */ 25 | #define T Cidr_T 26 | 27 | typedef struct T *T; 28 | 29 | extern T cidr_new(const char *str); 30 | extern const char * cidr_repr(T); 31 | extern int cidr_match(T, T); 32 | extern void cidr_free(T *); 33 | 34 | #undef T 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/dm_quota.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later 8 | version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #ifndef DM_QUOTA_H 21 | #define DM_QUOTA_H 22 | 23 | #include "dbmailtypes.h" 24 | 25 | #define T Quota_T 26 | 27 | typedef struct T *T; 28 | 29 | extern uint64_t quota_get_usage(T); 30 | extern uint64_t quota_get_limit(T); 31 | extern void quota_free(T *); 32 | extern const char * quota_get_root(T); 33 | extern T quota_get_quota(uint64_t, const char *, char **); 34 | 35 | #undef T 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/dm_mempool.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later 8 | version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | */ 20 | #ifndef DM_MEMPOOL_H 21 | #define DM_MEMPOOL_H 22 | /* 23 | * provide simple memory pool 24 | */ 25 | #define M Mempool_T 26 | 27 | typedef struct M *M; 28 | 29 | extern M mempool_open(void); 30 | extern void * mempool_pop(M, size_t); 31 | extern void * mempool_resize(M, void *, size_t, size_t); 32 | extern void mempool_push(M, void *, size_t); 33 | extern void mempool_close(M *); 34 | 35 | #undef M 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /test-scripts/imapbench.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | import argparse 4 | import time 5 | import imaplib 6 | 7 | 8 | def bencher(args): 9 | host = args.host 10 | port = int(args.port) 11 | login = args.login 12 | password = args.password 13 | count = int(args.count) 14 | before = time.time() 15 | for x in range(0, count): 16 | conn = imaplib.IMAP4(host, port) 17 | conn.login(login, password) 18 | conn.logout() 19 | after = time.time() 20 | return after - before 21 | 22 | 23 | if __name__ == '__main__': 24 | COUNT = 100 25 | HOST = '127.0.0.1' 26 | PORT = 10143 27 | LOGIN = 'testuser1' 28 | PASSWORD = 'test' 29 | 30 | parser = argparse.ArgumentParser(description='simple IMAP benchmark') 31 | parser.add_argument('--host', default=HOST) 32 | parser.add_argument('--port', default=PORT) 33 | parser.add_argument('--count', default=COUNT) 34 | parser.add_argument('--login', default=LOGIN) 35 | parser.add_argument('--password', default=PASSWORD) 36 | args = parser.parse_args() 37 | 38 | print sys.argv[0] 39 | print 40 | print "testing: login/logout" 41 | print "count: ", args.count 42 | delay = bencher(args) 43 | print "time: ", delay 44 | 45 | 46 | #EOF 47 | -------------------------------------------------------------------------------- /src/dm_digest.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later 8 | version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | */ 20 | 21 | #ifndef DM_DIGEST_H 22 | #define DM_DIGEST_H 23 | 24 | int dm_digest(const unsigned char * hash, hashid type, char *); 25 | int dm_tiger(const char * const s, char *); 26 | int dm_sha1(const char * const s, char *); 27 | int dm_sha256(const char * const s, char *); 28 | int dm_sha512(const char * const s, char *); 29 | int dm_whirlpool(const char * const s, char *); 30 | int dm_md5(const char * const s, char *); 31 | int dm_md5_base64(const char * const s, char *); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /man/dbmail.txt: -------------------------------------------------------------------------------- 1 | DBMAIL(1) 2 | ========= 3 | Author 4 | 5 | NAME 6 | ---- 7 | dbmail - the Database Mailer, is a suite of mail storage and 8 | retrieval programs centered around a database backend. 9 | 10 | SYNOPSIS 11 | -------- 12 | See one of the following man pages for more information about the components 13 | of a DBMail system: 14 | 15 | |========================================================================== 16 | | Configuration file | link:dbmail.conf.html[dbmail.conf(5)] 17 | | Deliver mail | link:dbmail-deliver.html[dbmail-deliver(1)] 18 | | Manage user accounts | link:dbmail-users.html[dbmail-users(8)] 19 | | Export mailbox contents | link:dbmail-export.html[dbmail-export(8)] 20 | | Manage Sieve scripts | link:dbmail-sievecmd.html[dbmail-sievecmd(8)] 21 | | Maintain health | link:dbmail-util.html[dbmail-util(8)] 22 | | IMAP daemon | link:dbmail-imapd.html[dbmail-imapd(8)] 23 | | POP3 daemon | link:dbmail-pop3d.html[dbmail-pop3d(8)] 24 | | LMTP daemon | link:dbmail-lmtpd.html[dbmail-lmtpd(8)] 25 | | HTTP daemon | link:dbmail-httpd.html[dbmail-httpd(8)] 26 | | ManageSieve daemon | link:dbmail-timsieved.html[dbmail-timsieved(8)] 27 | |========================================================================== 28 | 29 | include::footer.txt[] 30 | -------------------------------------------------------------------------------- /src/dm_capa.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2009-2012 NFG Net Facilities Group BV support@nfg.nl 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef DM_CAPA_H 22 | #define DM_CAPA_H 23 | 24 | #include 25 | #include "dm_mempool.h" 26 | 27 | typedef struct Capa_T *Capa_T; 28 | 29 | extern Capa_T Capa_new(Mempool_T); 30 | extern const gchar * Capa_as_string(Capa_T); 31 | extern gboolean Capa_match(Capa_T, const char *); 32 | extern void Capa_add(Capa_T, const char *); 33 | extern void Capa_remove(Capa_T, const char *); 34 | extern void Capa_free(Capa_T *); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /test-scripts/imap/append: -------------------------------------------------------------------------------- 1 | connections: 3 2 | state: created 3 | 4 | 1 ok select $mailbox 5 | 2 ok select $mailbox 6 | 7 | # Two connections have mailbox SELECTed, one doesn't. 8 | # The \recent flags can be given to either one of the SELECTed connections, 9 | # but never for the 3rd. We rely on mailbox state tracking to catch duplicate 10 | # \recent flags (which is why there are two FETCH FLAGS commands). 11 | 12 | 1 ok append $mailbox (\seen \flagged) 13 | * 1 exists 14 | 2 ok noop 15 | * 1 exists 16 | 3 ok status $mailbox (messages unseen recent) 17 | * status $mailbox (messages 1 unseen 0 recent 0) 18 | 1 ok fetch 1 (uid flags) 19 | * 1 fetch (uid $uid1 flags (\seen \flagged)) 20 | 2 ok fetch 1 (uid flags) 21 | * 1 fetch (uid $uid1 flags (\seen \flagged)) 22 | 23 | 2 ok append 24 | * 2 exists 25 | 1 ok noop 26 | * 2 exists 27 | 3 ok status $mailbox (messages unseen recent) 28 | * status $mailbox (messages 2 unseen 1 recent 0) 29 | 1 ok fetch 2 (uid flags) 30 | 2 ok fetch 2 (uid flags) 31 | 32 | 3 ok append 33 | 3 ok status $mailbox (messages unseen) 34 | * status $mailbox (messages 3 unseen 2) 35 | 2 ok noop 36 | * 3 exists 37 | 1 ok noop 38 | * 3 exists 39 | 1 ok fetch 3 (uid flags) 40 | 2 ok fetch 3 (uid flags) 41 | 42 | 1 append ${mailbox}nonexistent 43 | no [trycreate] 44 | 45 | 1 ok append $mailbox 46 | * 4 exists 47 | * 1 recent 48 | 49 | -------------------------------------------------------------------------------- /test-scripts/imap/copy: -------------------------------------------------------------------------------- 1 | connections: 2 2 | state: created 3 | 4 | 1 ok select ${mailbox} 5 | 1 ok append 6 | 1 ok append 7 | 1 ok append 8 | 1 ok append 9 | 1 ok append 10 | # make sure the server sees the appended messages 11 | 1 ok check 12 | 13 | 2 "" delete ${mailbox}2 14 | 2 ok create ${mailbox}2 15 | 2 ok select ${mailbox}2 16 | 17 | 1 ok store 1 flags (\seen) 18 | 1 ok store 2 flags (\answered \flagged) 19 | 1 ok store 5 flags (\flagged $$keyword1 $$keyword2) 20 | 21 | 1 ok fetch 1:5 (internaldate) 22 | * 1 fetch (internaldate $date1) 23 | * 2 fetch (internaldate $date2) 24 | * 4 fetch (internaldate $date4) 25 | * 5 fetch (internaldate $date5) 26 | 1 ok copy 1:2,4 ${mailbox}2 27 | 28 | 2 ok noop 29 | * 3 exists 30 | * 3 recent 31 | 32 | 2 ok fetch 1:3 (flags internaldate) 33 | * 1 fetch (flags (\recent \seen) internaldate $date1) 34 | * 2 fetch (flags (\recent \answered \flagged) internaldate $date2) 35 | * 3 fetch (flags (\recent) internaldate $date4) 36 | 37 | # keywords aren't required to be created on COPY, so help the server here 38 | 2 ok store 3 +flags ($$keyword1 $$keyword2) 39 | 40 | 1 ok copy 5 ${mailbox}2 41 | 2 ok noop 42 | * 4 exists 43 | * 4 recent 44 | 45 | 2 ok fetch 4 (flags internaldate) 46 | * 4 fetch (flags (\recent \flagged $$keyword1 $$keyword2) internaldate $date5) 47 | 48 | 2 ok close 49 | 2 "" delete ${mailbox}2 50 | -------------------------------------------------------------------------------- /doc/README.filters: -------------------------------------------------------------------------------- 1 | 2 | README.filters 3 | 4 | DBMail support simple SQL bases filter rules. These can be assigned 5 | per user, or globally by assigning them to the 'anyone' user. 6 | 7 | 8 | The dbmail_filters table contains the following fields: 9 | 10 | id BIGINT NOT NULL AUTO_INCREMENT 11 | user_id BIGINT NOT NULL 12 | headername varchar(128) NOT NULL 13 | headervalue varchar(255) NOT NULL 14 | mailbox varchar(100) NOT NULL 15 | 16 | Headernames in this table must be lower-cased since they are joined 17 | on the dbmail_headernames table which only contains lower-cased values. 18 | 19 | Headervalues are matched as case-insensitive LIKE. They may contain LIKE-style 20 | match expressions. 21 | 22 | So: 23 | 24 | If a message's headers look like: 25 | 26 | From: Foo Bar 27 | Subject: this is a test 28 | 29 | Rules would match as follows: 30 | 31 | | headername | headervalue | match? 32 | ---+--------------+--------------------------+------- 33 | | from | foobar@dot.com | no 34 | | from | Foo Bar | yes 35 | | from | %foobar@dot.com% | yes 36 | | subject | test | no 37 | | subject | test% | yes 38 | ---+--------------+--------------------------+------- 39 | 40 | 41 | -------------------------------------------------------------------------------- /test-scripts/testlmtp.txt: -------------------------------------------------------------------------------- 1 | LHLO host 2 | MAIL FROM: 3 | RCPT TO: 4 | DATA 5 | To: user@dom 6 | Subject: =?ISO-8859-2?Q?E-mail=20noviny=2016/06:=20Vli?= 7 | =?ISO-8859-2?Q?v=20p=F8=EDjm=F9=20ze=20zam=ECstn=E1n=ED=20n?= 8 | =?ISO-8859-2?Q?a=20z=E1lohy=20fyzick=FDch=20osob?= 9 | Sender: =?ISO-8859-2?Q? "Verlag=20Dash=F6fer=20-=20DU.cz?= 10 | =?ISO-8859-2?Q?" 11 | ?= 12 | Reply-To: =?ISO-8859-2?Q?Verlag=20Dash=F6fer=20?= 13 | From: =?ISO-8859-2?Q? "Verlag=20Dash=F6fer=20-=20DU.cz?= =?ISO-8859-2?Q?" 14 | ?= 15 | 22 | RCPT TO: 23 | DATA 24 | To: user@dom 25 | Subject: =?ISO-8859-2?Q?E-mail=20noviny=2016/06:=20Vli?= 26 | =?ISO-8859-2?Q?v=20p=F8=EDjm=F9=20ze=20zam=ECstn=E1n=ED=20n?= 27 | =?ISO-8859-2?Q?a=20z=E1lohy=20fyzick=FDch=20osob?= 28 | Sender: =?ISO-8859-2?Q? "Verlag=20Dash=F6fer=20-=20DU.cz?= 29 | =?ISO-8859-2?Q?" 30 | ?= 31 | Reply-To: =?ISO-8859-2?Q?Verlag=20Dash=F6fer=20?= 32 | From: =?ISO-8859-2?Q? "Verlag=20Dash=F6fer=20-=20DU.cz?= =?ISO-8859-2?Q?" 33 | ?= 34 | 25 | 26 | #define T Cram_T 27 | 28 | typedef struct T *T; 29 | 30 | extern T Cram_new(void); 31 | extern void Cram_setChallenge(T, const char *); 32 | extern const gchar * Cram_getChallenge(T); 33 | extern const gchar * Cram_getUsername(T); 34 | extern gboolean Cram_decode(T, const char *); 35 | extern gboolean Cram_verify(T, const char *); 36 | extern void Cram_free(T *); 37 | 38 | #undef T 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /test-scripts/imap/fetch: -------------------------------------------------------------------------------- 1 | messages: 3 2 | 3 | ok status $mailbox (uidnext) 4 | * status $mailbox (uidnext $uidnext) 5 | 6 | ok fetch 1:3 uid 7 | * 1 fetch (uid $uid1) 8 | * 2 fetch (uid $uid2) 9 | * 3 fetch (uid $uid3) 10 | 11 | ok fetch 3:1 uid 12 | * 1 fetch (uid $uid1) 13 | * 2 fetch (uid $uid2) 14 | * 3 fetch (uid $uid3) 15 | 16 | ok fetch 1,* uid 17 | * 1 fetch (uid $uid1) 18 | * 3 fetch (uid $uid3) 19 | 20 | ok fetch * uid 21 | * 3 fetch (uid $uid3) 22 | 23 | ok fetch *:1 uid 24 | * 1 fetch (uid $uid1) 25 | * 2 fetch (uid $uid2) 26 | * 3 fetch (uid $uid3) 27 | 28 | ok uid fetch $uidnext:* uid 29 | * 3 fetch (uid $uid3) 30 | 31 | # break seq=uid map 32 | ok store 2 flags \deleted 33 | ok expunge 34 | * 2 expunge 35 | 36 | ok uid fetch $uidnext:* uid 37 | * 2 fetch (uid $uid3) 38 | ok uid fetch 1:* uid 39 | * 1 fetch (uid $uid1) 40 | * 2 fetch (uid $uid3) 41 | ok uid fetch $uid2 uid 42 | ! 1 fetch (uid $uid1) 43 | ! 2 fetch (uid $uid3) 44 | ok uid fetch $uid1,* uid 45 | * 1 fetch (uid $uid1) 46 | * 2 fetch (uid $uid3) 47 | 48 | # test macros 49 | ok fetch 1 full 50 | * 1 fetch (flags () internaldate $intdate1 rfc822.size $size1 envelope ($!unordered) body ($!unordered)) 51 | ok fetch 1 all 52 | * 1 fetch (flags () internaldate $intdate1 rfc822.size $size1 envelope ($!unordered)) 53 | ok fetch 1 fast 54 | * 1 fetch (flags () internaldate $intdate1 rfc822.size $size1) 55 | -------------------------------------------------------------------------------- /contrib/nginx/mail.conf: -------------------------------------------------------------------------------- 1 | mail { 2 | auth_http http://localhost/auth.php; 3 | imap_capabilities "IMAP4rev1"; 4 | proxy on; 5 | ssl on; 6 | 7 | ssl_prefer_server_ciphers on; 8 | ssl_protocols TLSv1 SSLv3; 9 | ssl_ciphers HIGH:!ADH:!MD5:@STRENGTH; 10 | ssl_session_cache shared:TLSSL:16m; 11 | ssl_session_timeout 10m; 12 | ssl_certificate /etc/ssl/mail.example.org.pem; 13 | ssl_certificate_key /etc/ssl/mail.example.org.key; 14 | 15 | 16 | server { 17 | listen 995; 18 | protocol pop3; 19 | server_name mail.example.org; 20 | } 21 | 22 | server { 23 | listen 993; 24 | protocol imap; 25 | server_name mail.example.org; 26 | } 27 | } 28 | 29 | mail { 30 | auth_http http://localhost/auth.php; 31 | imap_capabilities "IMAP4rev1"; 32 | proxy on; 33 | starttls on; 34 | 35 | ssl_prefer_server_ciphers on; 36 | ssl_protocols TLSv1 SSLv3; 37 | ssl_ciphers HIGH:!ADH:!MD5:@STRENGTH; 38 | ssl_session_cache shared:TLSSL:16m; 39 | ssl_session_timeout 10m; 40 | ssl_certificate /etc/ssl/mail.example.org.pem; 41 | ssl_certificate_key /etc/ssl/mail.example.org.key; 42 | 43 | server { 44 | listen 110; 45 | protocol pop3; 46 | server_name mail.example.org; 47 | } 48 | server { 49 | listen 143; 50 | protocol imap; 51 | server_name mail.example.org; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/clientbase.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later 8 | version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | /* 21 | */ 22 | 23 | #ifndef DM_CLIENTBASE_H 24 | #define DM_CLIENTBASE_H 25 | 26 | #include "dbmail.h" 27 | 28 | ClientBase_T * client_init(client_sock *); 29 | 30 | int ci_starttls(ClientBase_T *); 31 | void ci_cork(ClientBase_T *); 32 | void ci_uncork(ClientBase_T *); 33 | void ci_authlog_init(ClientBase_T *, const char *, const char *, const char *); 34 | 35 | void ci_read_cb(ClientBase_T *); 36 | void ci_write_cb(ClientBase_T *); 37 | 38 | int ci_read(ClientBase_T *, char *, size_t); 39 | int ci_readln(ClientBase_T *, char *); 40 | int ci_write(ClientBase_T *, char *, ...); 41 | 42 | size_t ci_wbuf_len(ClientBase_T *); 43 | 44 | void ci_close(ClientBase_T *); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/dm_iconv.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later 8 | version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #ifndef DM_ICONV_H 21 | #define DM_ICONV_H 22 | 23 | #include "dbmail.h" 24 | 25 | struct DbmailIconv { 26 | Field_T db_charset; 27 | Field_T msg_charset; 28 | 29 | iconv_t to_db; 30 | iconv_t from_db; 31 | iconv_t from_msg; 32 | }; 33 | 34 | 35 | void dbmail_iconv_init(void); 36 | char * dbmail_iconv_str_to_db(const char* str_in, const char *charset); 37 | char * dbmail_iconv_str_to_utf8(const char* str_in, const char *charset); 38 | char * dbmail_iconv_db_to_utf7(const char* str_in); 39 | char * dbmail_iconv_decode_text(const char *in); 40 | char * dbmail_iconv_decode_address(char *address); 41 | char * dbmail_iconv_decode_field(const char *in, const char *charset, gboolean isaddr); 42 | 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/dm_match.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2006 Aaron Stone 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later 8 | version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | */ 20 | #ifndef DM_MATCH_H 21 | #define DM_MATCH_H 22 | 23 | // See if the needle matches the haystack, given 24 | // than '?' means zero or one character and '*' 25 | // means zero or any number of characters. 26 | // 27 | // Returns the candidate argument if it matches, or NULL. 28 | // Does not make a copy of candidate. This allows nesting. 29 | char *match_glob(char *pattern, char *candidate); 30 | 31 | // Returns a list of elements from the argument list that 32 | // match the pattern. DOES make a copy of matching elements. 33 | // The resulting GList should be freed with 34 | // g_list_foreach(glob_list, (GFunc)g_free, NULL) 35 | // g_list_free(glob_list); 36 | GList *match_glob_list(char *pattern, GList *list); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/sort.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Copyright (C) 1999-2004 Aaron Stone aaron at serendipity dot cx 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | /* Headers for sort.c */ 22 | 23 | #ifndef DM_SORT_H 24 | #define DM_SORT_H 25 | 26 | #define MAX_SIEVE_SCRIPTNAME 100 27 | 28 | typedef struct sort_result SortResult_T; 29 | 30 | SortResult_T *sort_process(uint64_t user_idnr, DbmailMessage *message, const char *mailbox); 31 | SortResult_T *sort_validate(uint64_t user_idnr, char *scriptname); 32 | const char *sort_listextensions(void); 33 | void sort_free_result(SortResult_T *sort_result); 34 | 35 | int sort_get_cancelkeep(SortResult_T *sort_result); 36 | int sort_get_reject(SortResult_T *sort_result); 37 | const char * sort_get_mailbox(SortResult_T *sort_result); 38 | const char * sort_get_errormsg(SortResult_T *sort_result); 39 | int sort_get_error(SortResult_T *sort_result); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /man/dbmail-sievecmd.txt: -------------------------------------------------------------------------------- 1 | DBMAIL-SIEVECMD(8) 2 | =================== 3 | 4 | 5 | NAME 6 | ---- 7 | dbmail-sievecmd - manipulates Sieve scripts in the DBMail database. 8 | 9 | SYNOPSIS 10 | -------- 11 | dbmail-sievecmd -u username [-l] [-a scriptname] [-d scriptname] 12 | [-i scriptname file] [-c [scriptname]] [-r scriptname] 13 | [-f configfile] [-nvVh] 14 | 15 | DESCRIPTION 16 | ----------- 17 | DBMail stores Sieve scripts in a table in the DBMail database. These 18 | scripts are used to sort incoming mail for the email users. Each user 19 | has their own script space and may upload scripts to the 20 | dbmail-timsieved(8) daemon. The dbmail-sievecmd(8) utility provides 21 | a convenient method for the system administrator to work with 22 | Sieve scripts from the command line. 23 | 24 | OPTIONS 25 | ------- 26 | 27 | -u username:: 28 | Specify the user whose scripts we will be modifying. 29 | 30 | -l:: 31 | List scripts belonging to user 32 | 33 | -a scriptname:: 34 | Activates `scriptname`, deactivating all other scripts. 35 | 36 | -d scriptname:: 37 | Deactivates `scriptname` if it was active. 38 | 39 | -i scriptname file:: 40 | Creates a script called `scriptname` by importing `file`. If `file` 41 | is - (dash) or unspecified, 'stdin' will be read. 42 | 43 | -c [scriptname]:: 44 | Print out the named script. If no script is given, the active 45 | script is printed. 46 | 47 | -r scriptname:: 48 | Remove the named script. If the script was active, no script will 49 | be active after it is deletion. 50 | 51 | 52 | include::commonopts.txt[] 53 | 54 | include::footer.txt[] 55 | -------------------------------------------------------------------------------- /man/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 2 | # 3 | # This program is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU General Public License 5 | # as published by the Free Software Foundation; either 6 | # version 2 of the License, or (at your option) any later 7 | # version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | 18 | man1_MANS = dbmail.1 dbmail-deliver.1 19 | 20 | man5_MANS = dbmail.conf.5 21 | 22 | man8_MANS = dbmail-util.8 \ 23 | dbmail-users.8 \ 24 | dbmail-export.8 \ 25 | dbmail-sievecmd.8 \ 26 | dbmail-imapd.8 \ 27 | dbmail-lmtpd.8 \ 28 | dbmail-pop3d.8 \ 29 | dbmail-httpd.8 \ 30 | dbmail-timsieved.8 31 | 32 | EXTRA_DIST = $(man1_MANS) $(man5_MANS) $(man8_MANS) 33 | 34 | %.html : %.txt 35 | asciidoc --unsafe -b xhtml11 -d manpage $< 36 | 37 | %.xml : %.txt 38 | asciidoc --unsafe -b docbook -d manpage $< 39 | 40 | %.1 : %.xml 41 | xmlto man $< 2>/dev/null 42 | ./fixsp.pl $@ 43 | 44 | %.5 : %.xml 45 | xmlto man $< 2>/dev/null 46 | ./fixsp.pl $@ 47 | 48 | %.8 : %.xml 49 | xmlto man $< 2>/dev/null 50 | ./fixsp.pl $@ 51 | 52 | clean: 53 | rm -f *1 *5 *8 *xml *html 54 | -------------------------------------------------------------------------------- /test-scripts/imap/expunge: -------------------------------------------------------------------------------- 1 | connections: 2 2 | messages: 8 3 | 4 | # get UIDs 5 | 1 ok fetch 1:4 uid 6 | * 1 fetch (uid $uid1) 7 | * 2 fetch (uid $uid2) 8 | * 3 fetch (uid $uid3) 9 | * 4 fetch (uid $uid4) 10 | 11 | # 1) test that expunges work ok and session 2 fetch sees 1's flag changes. 12 | 1 ok store 1,3 flags \deleted 13 | * 1 fetch (flags (\deleted)) 14 | * 3 fetch (flags (\deleted)) 15 | 1 ok store 2,4 flags \seen 16 | * 2 fetch (flags (\seen)) 17 | * 4 fetch (flags (\seen)) 18 | 1 ok expunge 19 | * $1 expunge 20 | * $3 expunge 21 | 22 | 2 ok fetch 2,4 (uid) 23 | * 2 fetch (uid $uid2) 24 | * 4 fetch (uid $uid4) 25 | 2 ok fetch 2,4 (uid) 26 | * 2 fetch (uid $uid2) 27 | * 4 fetch (uid $uid4) 28 | 2 ok check 29 | * $1 expunge 30 | * $3 expunge 31 | 2 ok fetch 1:2 (uid flags) 32 | * 1 fetch (uid $uid2 flags (\seen)) 33 | * 2 fetch (uid $uid4 flags (\seen)) 34 | 35 | # 2) test that session 2 can update flags while some messages are expunged 36 | 1 ok store 2 +flags \deleted 37 | 1 ok expunge 38 | 39 | 2 ok store 1 flags \answered 40 | * 1 fetch (flags (\answered)) 41 | 1 ok check 42 | * 1 fetch (flags (\answered)) 43 | 2 ok noop 44 | * 2 expunge 45 | 46 | # 3) check notices flag changes correctly with expunges 47 | 1 ok store 1,3 +flags \deleted 48 | 1 ok store 2,4 flags \flagged 49 | 1 ok expunge 50 | 2 ok check 51 | * $1 expunge 52 | * $2 fetch (flags (\flagged)) 53 | * $3 expunge 54 | * $4 fetch (flags (\flagged)) 55 | 56 | # 4) expunging while message is already expunged 57 | 1 ok store 1 +flags \deleted 58 | 2 ok store 1 +flags \deleted 59 | 1 ok expunge 60 | * 1 expunge 61 | 2 ok expunge 62 | * 1 expunge 63 | -------------------------------------------------------------------------------- /sql/sqlite/trigger.tmpl.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- table_a.key_a references table_b(key_b) 3 | -- on update cascade 4 | -- on delete cascade 5 | -- 6 | DROP TRIGGER IF EXISTS fk_insert_#TABLE_A#_#TABLE_B#_#KEY_B#; 7 | CREATE TRIGGER fk_insert_#TABLE_A#_#TABLE_B#_#KEY_B# 8 | BEFORE INSERT ON dbmail_#TABLE_A# 9 | FOR EACH ROW BEGIN 10 | SELECT CASE 11 | WHEN (new.#KEY_A# IS NOT NULL) 12 | AND ((SELECT #KEY_B# FROM dbmail_#TABLE_B# WHERE #KEY_B# = new.#KEY_A#) IS NULL) 13 | THEN RAISE (ABORT, 'insert on table "dbmail_#TABLE_A#" violates foreign key constraint "fk_insert_#TABLE_A#_#TABLE_B#_#KEY_B#"') 14 | END; 15 | END; 16 | 17 | DROP TRIGGER IF EXISTS fk_update_#TABLE_A#_#TABLE_B#_#KEY_B#; 18 | CREATE TRIGGER fk_update_#TABLE_A#_#TABLE_B#_#KEY_B# 19 | BEFORE UPDATE ON dbmail_#TABLE_A# 20 | FOR EACH ROW BEGIN 21 | SELECT CASE 22 | WHEN (new.#KEY_A# IS NOT NULL) 23 | AND ((SELECT #KEY_B# FROM dbmail_#TABLE_B# WHERE #KEY_B# = new.#KEY_A#) IS NULL) 24 | THEN RAISE (ABORT, 'update on table "dbmail_#TABLE_A#" violates foreign key constraint "fk_update_#TABLE_A#_#TABLE_B#_#KEY_B#"') 25 | END; 26 | END; 27 | 28 | DROP TRIGGER IF EXISTS fk_update2_#TABLE_A#_#TABLE_B#_#KEY_B#; 29 | CREATE TRIGGER fk_update2_#TABLE_A#_#TABLE_B#_#KEY_B# 30 | AFTER UPDATE ON dbmail_#TABLE_B# 31 | FOR EACH ROW BEGIN 32 | UPDATE dbmail_#TABLE_A# SET #KEY_A# = new.#KEY_B# WHERE #KEY_A# = OLD.#KEY_B#; 33 | END; 34 | 35 | DROP TRIGGER IF EXISTS fk_delete_#TABLE_A#_#TABLE_B#_#KEY_B#; 36 | CREATE TRIGGER fk_delete_#TABLE_A#_#TABLE_B#_#KEY_B# 37 | BEFORE DELETE ON dbmail_#TABLE_B# 38 | FOR EACH ROW BEGIN 39 | DELETE FROM dbmail_#TABLE_A# WHERE #KEY_A# = OLD.#KEY_B#; 40 | END; 41 | 42 | -------------------------------------------------------------------------------- /src/clientsession.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004 IC & S dbmail@ic-s.nl 3 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef DM_CLIENTSESSION_H 22 | 23 | #define DM_CLIENTSESSION_H 24 | 25 | ClientSession_T * client_session_new(client_sock *c); 26 | 27 | void client_session_read(void *arg); // read event callback 28 | 29 | void client_session_reset(ClientSession_T * session); 30 | void client_session_reset_parser(ClientSession_T *session); 31 | void client_session_bailout(ClientSession_T **session); 32 | void client_session_set_timeout(ClientSession_T *session, int timeout); 33 | 34 | void socket_read_cb(int fd, short what, void *arg); 35 | void socket_write_cb(int fd, short what, void *arg); 36 | 37 | int pop3_handle_connection(client_sock *c); 38 | int imap_handle_connection(client_sock *c); 39 | int tims_handle_connection(client_sock *c); 40 | int lmtp_handle_connection(client_sock *c); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/lmtpd.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 3 | Copyright (C) 2006 Aaron Stone aaron@serendipity.cx 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | /* 22 | * 23 | * lmtpd.c 24 | * 25 | * main prg for lmtp daemon 26 | */ 27 | 28 | #include "dbmail.h" 29 | #define THIS_MODULE "lmtpd" 30 | #define PNAME "dbmail/lmtpd" 31 | 32 | int main(int argc, char *argv[]) 33 | { 34 | ServerConfig_T config; 35 | int result; 36 | 37 | openlog(PNAME, LOG_PID, LOG_MAIL); 38 | memset(&config, 0, sizeof(ServerConfig_T)); 39 | result = server_getopt(&config, "LMTP", argc, argv); 40 | if (result == -1) goto shutdown; 41 | if (result == 1) { 42 | server_showhelp("dbmail-lmtpd", 43 | "This daemon provides Local Mail Transport Protocol services."); 44 | goto shutdown; 45 | } 46 | 47 | config.ClientHandler = lmtp_handle_connection; 48 | result = server_mainloop(&config, "dbmail-lmtpd"); 49 | shutdown: 50 | TRACE(TRACE_INFO, "exit"); 51 | return result; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /test-scripts/imap/subscribe: -------------------------------------------------------------------------------- 1 | connections: 2 2 | state: auth 3 | 4 | # get the separator 5 | 1 ok list "" "" 6 | * list () $sep $root 7 | 8 | 1 "" unsubscribe $mailbox${sep}test 9 | 1 "" unsubscribe $mailbox${sep}test2 10 | 1 "" unsubscribe $mailbox${sep}test2${sep}test 11 | 1 "" unsubscribe $mailbox${sep}test3${sep}test3 12 | 13 | 1 ok create $mailbox${sep} 14 | 1 ok create $mailbox${sep}test 15 | 1 ok create $mailbox${sep}test2${sep} 16 | 1 ok create $mailbox${sep}test3${sep} 17 | 1 ok create $mailbox${sep}test2${sep}test 18 | 1 ok create $mailbox${sep}test3${sep}test3 19 | # create the test2 mailbox only if server supports inferior mailboxes 20 | 1 "" create $mailbox${sep}test2 21 | 22 | 1 ok subscribe $mailbox${sep}test 23 | 1 ok subscribe $mailbox${sep}test2${sep}test 24 | 1 ok subscribe $mailbox${sep}test3${sep}test3 25 | 26 | 2 ok lsub "" $mailbox${sep}% 27 | * lsub () $sep $mailbox${sep}test 28 | * lsub (\noselect) $sep $mailbox${sep}test2 29 | * lsub (\noselect) $sep $mailbox${sep}test3 30 | ! lsub (\noselect) $sep $mailbox${sep}test2${sep}test 31 | ! lsub (\noselect) $sep $mailbox${sep}test3${sep}test3 32 | 33 | 2 ok lsub "" *test 34 | * lsub () $sep $mailbox${sep}test 35 | * lsub () $sep $mailbox${sep}test2${sep}test 36 | ! lsub () $sep $mailbox${sep}test3${sep}test3 37 | 38 | 1 ok unsubscribe $mailbox${sep}test 39 | 2 ok lsub "" $mailbox${sep}% 40 | ! lsub () $sep $mailbox${sep}test 41 | 42 | 1 ok unsubscribe $mailbox${sep}test2${sep}test 43 | 2 ok lsub "" $mailbox${sep}* 44 | ! lsub () $sep $mailbox${sep}test 45 | * lsub () $sep $mailbox${sep}test3${sep}test3 46 | 47 | 1 ok unsubscribe $mailbox${sep}test3${sep}test3 48 | 2 ok lsub "" $mailbox${sep}% 49 | ! lsub () $sep $mailbox${sep}test3 50 | -------------------------------------------------------------------------------- /man/dbmail-deliver.txt: -------------------------------------------------------------------------------- 1 | DBMAIL-DELIVER(1) 2 | ================= 3 | 4 | NAME 5 | ---- 6 | dbmail-deliver - inserts messages into the DBMail mailsystem. 7 | 8 | 9 | SYNOPSIS 10 | -------- 11 | dbmail-deliver [-t headerfield] [-d addresses] [-u usernames] [-m|-M mailboxname] 12 | [-r return path] [-f configFile] 13 | 14 | DESCRIPTION 15 | ----------- 16 | The dbmail-deliver program inserts messages from the commandline or from 17 | any MTA into the DBMail mailsystem. The program reads from standard input. 18 | 19 | 20 | OPTIONS 21 | ------- 22 | -t headerfield:: 23 | Deliver messages to the recipient MIME header specified in 24 | headerfield. The default header to use is the "Delivered-To:" 25 | header. 26 | 27 | -d addresses...:: 28 | Deliver messages to the recipients specified by addresses. This 29 | option is mostly used for delivery from an MTA. Separate multiple 30 | addresses by spaces. 31 | 32 | -u usernames...:: 33 | Deliver messages straight to the given username. 34 | Separate multiple usernames with spaces. 35 | 36 | -m mailboxname:: 37 | Deliver messages to mailbox mailboxname of the recipient. If 38 | this mailbox does not exist yet, it is created. Sieve scripts 39 | will be run normally, possibly altering the destination mailbox. 40 | 41 | -M mailboxname:: 42 | Deliver messages to mailbox mailboxname of the recipient. If 43 | this mailbox does not exist yet, it is created. Sieve scripts 44 | are not run. Permission checks are not performed for mailbox creation 45 | or message delivery. 46 | 47 | -r returnpath:: 48 | Set return path for bounces and other error reports to return path. 49 | 50 | 51 | include::commonopts.txt[] 52 | 53 | include::footer.txt[] 54 | -------------------------------------------------------------------------------- /src/modules/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 3 | # Copyright (c) 2004-2010 NFG Net Facilities Group BV support@nfg.nl 4 | # 5 | # This program is free software; you can redistribute it and/or 6 | # modify it under the terms of the GNU General Public License 7 | # as published by the Free Software Foundation; either 8 | # version 2 of the License, or (at your option) any later 9 | # version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | AM_CPPFLAGS = -I$(top_srcdir)/src 21 | AM_CFLAGS = @LDAPINC@ @SIEVEINC@ 22 | 23 | if SHARED 24 | AM_LDFLAGS = -module 25 | else 26 | AM_LDFLAGS = 27 | endif 28 | 29 | noinst_LTLIBRARIES = libsort_null.la 30 | 31 | # This one is always built. 32 | libsort_null_la_SOURCES = sortnull.c 33 | 34 | if SIEVE 35 | libsort_sieve_la_SOURCES = sortsieve.c 36 | libsort_sieve_la_LIBADD = @SIEVELIB@ 37 | dbmail_sieve_la = libsort_sieve.la 38 | endif 39 | 40 | # This one is always built. 41 | libauth_sql_la_SOURCES = authsql.c 42 | libauth_sql_la_LIBADD = @CRYPTLIB@ 43 | 44 | if LDAP 45 | libauth_ldap_la_SOURCES = authldap.c 46 | libauth_ldap_la_LIBADD = @CRYPTLIB@ @LDAPLIB@ 47 | dbmail_ldap_la = libauth_ldap.la 48 | endif 49 | 50 | pkglib_LTLIBRARIES = $(dbmail_sieve_la) \ 51 | $(dbmail_ldap_la) \ 52 | libauth_sql.la 53 | 54 | -------------------------------------------------------------------------------- /src/dm_sset.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2010-2012 NFG Net Facilities Group BV support@nfg.nl 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | /* 22 | * ADT interface for Sorted Set 23 | * 24 | * optimized for insertion and removal of items to and from the 25 | * Universe 26 | */ 27 | 28 | 29 | #ifndef DM_SSET_H 30 | #define DM_SSET_H 31 | 32 | #define T Sset_T 33 | 34 | typedef struct T *T; 35 | 36 | extern T Sset_new(int (*cmp)(const void *, const void *), size_t, void (*free)(void *)); 37 | extern int Sset_has(T, const void *); 38 | extern void Sset_add(T, const void *); 39 | extern int Sset_len(T); 40 | extern void Sset_del(T, const void *); 41 | extern void Sset_map(T, int (*func)(void *, void *), void *); 42 | extern void Sset_free(T *); 43 | 44 | extern T Sset_or(T, T); // a + b 45 | extern T Sset_and(T, T); // a * b 46 | extern T Sset_not(T, T); // a - b 47 | extern T Sset_xor(T, T); // a / b 48 | 49 | #undef T 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/mpool/README: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------- 2 | $Id: README,v 1.2 2005/05/22 19:49:30 gray Exp $ 3 | ------------------------------------------------------------------------------- 4 | 5 | BACKGROUND: 6 | 7 | This is a memory pool library which was written to allow a program to 8 | have heaps that it could destroy without fragmenting memory. You can 9 | have multiple heaps and reset them easily completely reclaiming the 10 | memory (as opposed to standard heaps). 11 | 12 | With it you can mpool_open() a new heap, then mpool_alloc(), 13 | mpool_calloc(), mpool_realloc(), mpool_free() to your heart's content. 14 | Once you are done with the memory-pool you can run mpool_clear() or 15 | mpool_close() and completely remove the memory associated with the 16 | pools. This is very handy if you are working with some large blocks 17 | of memory and want to reset back to a clean state. 18 | 19 | Check out the mpool.h file for more information. Sorry for minimal 20 | docs. 21 | 22 | ------------------------------------------------------------------------------- 23 | 24 | INSTALLATION: 25 | 26 | 1) Typing 'make' should be enough to build libskip.a. 27 | 2) Typing 'make tests' should make the mpool_t test program. 28 | 29 | ------------------------------------------------------------------------------- 30 | 31 | REPOSITORY: 32 | 33 | The newest versions of the library are available from: 34 | 35 | http://256.com/sources/mpool/ 36 | 37 | ------------------------------------------------------------------------------- 38 | 39 | AUTHOR: 40 | 41 | If you have any questions or problems feel free to send me mail. 42 | 43 | Gray Watson 44 | http://256.com/gray/ 45 | 46 | ------------------------------------------------------------------------------- 47 | -------------------------------------------------------------------------------- /contrib/startup-scripts/redhat/dbmail-imapd.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Startup script for the DBMail Imap Server 4 | # 5 | # chkconfig: - 81 19 6 | # description: DBMail is a mail server with a database backend. Unlike \ 7 | # WUimapd it does not run through inetd. 8 | # processname: dbmail-imapd 9 | # pidfile: /var/run/dbmail-imapd.pid 10 | # config: /etc/dbmail.conf 11 | 12 | # Source function library. 13 | . /etc/rc.d/init.d/functions 14 | 15 | if [ -f /etc/sysconfig/dbmail ]; then 16 | . /etc/sysconfig/dbmail 17 | fi 18 | 19 | # Path to the dbmail script. 20 | dbmail=/usr/sbin/dbmail-imapd 21 | prog=dbmail-imapd 22 | RETVAL=0 23 | 24 | start() { 25 | pid=`pidof $prog` 26 | if [ -n "$pid" ] 27 | then 28 | echo "dbmail pop daemon is already running, PID $pid" 29 | else 30 | echo -n $"Starting $prog: " 31 | daemon $dbmail 32 | RETVAL=$? 33 | echo 34 | [ $RETVAL = 0 ] && touch /var/lock/subsys/$prog 35 | return $RETVAL 36 | fi 37 | } 38 | stop() { 39 | echo -n $"Stopping $prog: " 40 | killproc $dbmail 41 | RETVAL=$? 42 | echo 43 | [ $RETVAL = 0 ] && rm -f /var/lock/subsys/$prog /var/run/$prog.pid 44 | } 45 | reload() { 46 | echo -n $"Reloading $prog: " 47 | killproc $dbmail -HUP 48 | RETVAL=$? 49 | echo 50 | } 51 | 52 | # See how we were called. 53 | case "$1" in 54 | start) 55 | start 56 | ;; 57 | stop) 58 | stop 59 | ;; 60 | status) 61 | status $dbmail 62 | RETVAL=$? 63 | ;; 64 | restart) 65 | stop 66 | start 67 | ;; 68 | condrestart) 69 | if [ -f /var/run/$prog.pid ] ; then 70 | stop 71 | start 72 | fi 73 | ;; 74 | reload) 75 | reload 76 | ;; 77 | *) 78 | echo $"Usage: $prog {start|stop|restart|condrestart|reload|status}" 79 | exit 1 80 | esac 81 | 82 | exit $RETVAL 83 | -------------------------------------------------------------------------------- /contrib/startup-scripts/redhat/dbmail-lmtpd.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Startup script for the DBMail Lmtp Server 4 | # 5 | # chkconfig: - 81 19 6 | # description: DBMail is a mail server with a database backend. Unlike \ 7 | # WUimapd it does not run through inetd. 8 | # processname: dbmail-lmtpd 9 | # pidfile: /var/run/dbmail-lmtpd.pid 10 | # config: /etc/dbmail.conf 11 | 12 | # Source function library. 13 | . /etc/rc.d/init.d/functions 14 | 15 | if [ -f /etc/sysconfig/dbmail ]; then 16 | . /etc/sysconfig/dbmail 17 | fi 18 | 19 | # Path to the dbmail script. 20 | dbmail=/usr/sbin/dbmail-lmtpd 21 | prog=dbmail-lmtpd 22 | RETVAL=0 23 | 24 | start() { 25 | pid=`pidof $prog` 26 | if [ -n "$pid" ] 27 | then 28 | echo "dbmail pop daemon is already running, PID $pid" 29 | else 30 | echo -n $"Starting $prog: " 31 | daemon $dbmail 32 | RETVAL=$? 33 | echo 34 | [ $RETVAL = 0 ] && touch /var/lock/subsys/$prog 35 | return $RETVAL 36 | fi 37 | } 38 | stop() { 39 | echo -n $"Stopping $prog: " 40 | killproc $dbmail 41 | RETVAL=$? 42 | echo 43 | [ $RETVAL = 0 ] && rm -f /var/lock/subsys/$prog /var/run/$prog.pid 44 | } 45 | reload() { 46 | echo -n $"Reloading $prog: " 47 | killproc $dbmail -HUP 48 | RETVAL=$? 49 | echo 50 | } 51 | 52 | # See how we were called. 53 | case "$1" in 54 | start) 55 | start 56 | ;; 57 | stop) 58 | stop 59 | ;; 60 | status) 61 | status $dbmail 62 | RETVAL=$? 63 | ;; 64 | restart) 65 | stop 66 | start 67 | ;; 68 | condrestart) 69 | if [ -f /var/run/$prog.pid ] ; then 70 | stop 71 | start 72 | fi 73 | ;; 74 | reload) 75 | reload 76 | ;; 77 | *) 78 | echo $"Usage: $prog {start|stop|restart|condrestart|reload|status}" 79 | exit 1 80 | esac 81 | 82 | exit $RETVAL 83 | -------------------------------------------------------------------------------- /contrib/startup-scripts/redhat/dbmail-pop3d.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Startup script for the DBMail Pop3 Server 4 | # 5 | # chkconfig: - 81 19 6 | # description: DBMail is a mail server with a database backend. Unlike \ 7 | # WUimapd it does not run through inetd. 8 | # processname: dbmail-pop3d 9 | # pidfile: /var/run/dbmail-pop3d.pid 10 | # config: /etc/dbmail.conf 11 | 12 | # Source function library. 13 | . /etc/rc.d/init.d/functions 14 | 15 | if [ -f /etc/sysconfig/dbmail ]; then 16 | . /etc/sysconfig/dbmail 17 | fi 18 | 19 | # Path to the dbmail script. 20 | dbmail=/usr/sbin/dbmail-pop3d 21 | prog=dbmail-pop3d 22 | RETVAL=0 23 | 24 | start() { 25 | pid=`pidof $prog` 26 | if [ -n "$pid" ] 27 | then 28 | echo "dbmail pop daemon is already running, PID $pid" 29 | else 30 | echo -n $"Starting $prog: " 31 | daemon $dbmail 32 | RETVAL=$? 33 | echo 34 | [ $RETVAL = 0 ] && touch /var/lock/subsys/$prog 35 | return $RETVAL 36 | fi 37 | } 38 | stop() { 39 | echo -n $"Stopping $prog: " 40 | killproc $dbmail 41 | RETVAL=$? 42 | echo 43 | [ $RETVAL = 0 ] && rm -f /var/lock/subsys/$prog /var/run/$prog.pid 44 | } 45 | reload() { 46 | echo -n $"Reloading $prog: " 47 | killproc $dbmail -HUP 48 | RETVAL=$? 49 | echo 50 | } 51 | 52 | # See how we were called. 53 | case "$1" in 54 | start) 55 | start 56 | ;; 57 | stop) 58 | stop 59 | ;; 60 | status) 61 | status $dbmail 62 | RETVAL=$? 63 | ;; 64 | restart) 65 | stop 66 | start 67 | ;; 68 | condrestart) 69 | if [ -f /var/run/$prog.pid ] ; then 70 | stop 71 | start 72 | fi 73 | ;; 74 | reload) 75 | reload 76 | ;; 77 | *) 78 | echo $"Usage: $prog {start|stop|restart|condrestart|reload|status}" 79 | exit 1 80 | esac 81 | 82 | exit $RETVAL 83 | -------------------------------------------------------------------------------- /sql/sqlite/2_1_7-2_2_0.sqlite: -------------------------------------------------------------------------------- 1 | 2 | -- support faster FETCH commands by caching BODYSTRUCTURE and ENVELOPE information 3 | 4 | CREATE TABLE dbmail_envelope ( 5 | physmessage_id INTEGER NOT NULL, 6 | id INTEGER NOT NULL PRIMARY KEY, 7 | envelope TEXT NOT NULL DEFAULT '' 8 | ); 9 | 10 | CREATE UNIQUE INDEX dbmail_envelope_1 on dbmail_envelope (physmessage_id, envelope); 11 | 12 | -- FOREIGN KEY (physmessage_id) 13 | -- REFERENCES dbmail_physmessage(id) 14 | -- ON UPDATE CASCADE ON DELETE CASCADE 15 | 16 | CREATE TRIGGER fk_insert_envelope_physmessage_id 17 | BEFORE INSERT ON dbmail_envelope 18 | FOR EACH ROW BEGIN 19 | SELECT CASE 20 | WHEN (new.physmessage_id IS NOT NULL) 21 | AND ((SELECT id FROM dbmail_physmessage WHERE id = new.physmessage_id) IS NULL) 22 | THEN RAISE (ABORT, 'insert on table "dbmail_envelope" violates foreign key constraint "fk_insert_envelope_physmessage_id"') 23 | END; 24 | END; 25 | CREATE TRIGGER fk_update1_envelope_physmessage_id 26 | BEFORE UPDATE ON dbmail_envelope 27 | FOR EACH ROW BEGIN 28 | SELECT CASE 29 | WHEN (new.physmessage_id IS NOT NULL) 30 | AND ((SELECT id FROM dbmail_physmessage WHERE id = new.physmessage_id) IS NULL) 31 | THEN RAISE (ABORT, 'update on table "dbmail_envelope" violates foreign key constraint "fk_update1_envelope_physmessage_id"') 32 | END; 33 | END; 34 | CREATE TRIGGER fk_update2_envelope_physmessage_id 35 | AFTER UPDATE ON dbmail_physmessage 36 | FOR EACH ROW BEGIN 37 | UPDATE dbmail_envelope SET physmessage_id = new.id WHERE physmessage_id = OLD.id; 38 | END; 39 | CREATE TRIGGER fk_delete_envelope_physmessage_id 40 | BEFORE DELETE ON dbmail_physmessage 41 | FOR EACH ROW BEGIN 42 | DELETE FROM dbmail_envelope WHERE physmessage_id = OLD.id; 43 | END; 44 | 45 | --- TODO: dbmail_bodystructure 46 | -------------------------------------------------------------------------------- /debian/patches/dbmail_conf: -------------------------------------------------------------------------------- 1 | Description: update dbmail.conf for debian policy 2 | Author: Paul J Stevens 3 | 4 | --- 5 | The information above should follow the Patch Tagging Guidelines, please 6 | checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here 7 | are templates for supplementary fields that you might want to add: 8 | 9 | Origin: , 10 | Bug: 11 | Bug-Debian: http://bugs.debian.org/ 12 | Bug-Ubuntu: https://launchpad.net/bugs/ 13 | Forwarded: 14 | Reviewed-By: 15 | Last-Update: 16 | 17 | --- a/dbmail.conf 18 | +++ b/dbmail.conf 19 | @@ -135,8 +135,8 @@ query_timeout = 300 20 | # Root privs are used to open a port, then privs 21 | # are dropped down to the user/group specified here. 22 | # 23 | -effective_user = nobody 24 | -effective_group = nogroup 25 | +effective_user = dbmail 26 | +effective_group = dbmail 27 | 28 | # 29 | # The IPv4 and/or IPv6 addresses the services will bind to. 30 | @@ -173,17 +173,17 @@ authlog = no 31 | # 32 | # logfile for stdout messages 33 | # 34 | -logfile = /var/log/dbmail.log 35 | +logfile = /var/log/dbmail/dbmail.log 36 | 37 | # 38 | # logfile for stderr messages 39 | # 40 | -errorlog = /var/log/dbmail.err 41 | +errorlog = /var/log/dbmail/dbmail.err 42 | 43 | # 44 | # directory for storing PID files 45 | # 46 | -pid_directory = /var/run 47 | +pid_directory = /var/run/dbmail 48 | 49 | # 50 | # directory for locating libraries (normally has a sane default compiled-in) 51 | -------------------------------------------------------------------------------- /jenkins/Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: buildout 3 | 4 | buildout: bin/buildout 5 | bin/buildout 6 | 7 | bin/buildout: bin/python2.7 8 | bin/pip install zc.buildout 9 | 10 | bin/python2.7: 11 | virtualenv --python=python2.7 --clear . 12 | 13 | test: buildout test-postgresql test-mysql 14 | 15 | test-postgresql: 16 | sed -i -e 's,^dburi.*,dburi = postgresql://127.0.0.1:5432/dbmail?user=dbmail\&password=dbmail,' ./etc/dbmail.conf 17 | $(MAKE) run-test 18 | 19 | test-mysql: 20 | sed -i -e 's,^dburi.*,dburi = mysql://127.0.0.1:3306/dbmail?user=dbmail\&password=dbmail\&charset=utf8,' ./etc/dbmail.conf 21 | $(MAKE) run-test 22 | 23 | run-test: 24 | bin/supervisorctl shutdown || true 25 | sleep 3 26 | bin/supervisord && sleep 3 27 | (cd ../ && CK_FORK=no make check) 28 | sbin/dbmail-users -c testuser1 -w test -p plaintext || true 29 | sbin/dbmail-users -a testuser2 -w test -p plaintext || true 30 | sbin/dbmail-users -a testuser3 -w test -p sha256 || true 31 | sbin/dbmail-users -y -e testuser1 || true 32 | bin/py ../contrib/mailbox2dbmail/mailbox2dbmail -u testuser1 -m ../test-scripts/testbox -t mbox -p sbin/dbmail-deliver 33 | timeout 300 imaptest user=testuser1 pass=test port=10143 test=../test-scripts/imap 34 | timeout 300 bin/py ../test-scripts/testimap.py -v 35 | bin/py ../contrib/mailbox2dbmail/mailbox2dbmail -u testuser1 -m ../test-scripts/testbox -t mbox -p sbin/dbmail-deliver 36 | timeout 300 bin/py ../test-scripts/testpop.py -v 37 | timeout 300 bin/py ../test-scripts/python/compare.py 38 | #timeout 300 bin/py ../test-scripts/python/loadlmtp.py 39 | #timeout 300 bin/py ../test-scripts/python/loadimap.py 40 | #timeout 300 bin/py ../test-scripts/python/loadpop.py 41 | /usr/bin/phpunit ../contrib/testdbmailclient.php 42 | bin/supervisorctl shutdown || true 43 | 44 | 45 | 46 | .PHONY: test run-test 47 | 48 | -------------------------------------------------------------------------------- /src/dm_request.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2008-2012 NFG Net Facilities Group BV, support@nfg.nl 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later 8 | version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | 21 | #ifndef DM_REQUEST_H 22 | #define DM_REQUEST_H 23 | 24 | #include "dbmail.h" 25 | 26 | #define T Request_T 27 | typedef struct T *T; 28 | 29 | extern T Request_new(struct evhttp_request *, void *); 30 | extern void Request_cb(struct evhttp_request *, void *); 31 | extern void Request_send(T, int, const char *, struct evbuffer *); 32 | extern void Request_error(T, int, const char *); 33 | extern void Request_header(T, const char *, const char *); 34 | extern void Request_setContentType(T, const char *); 35 | extern void Request_free(T *); 36 | 37 | extern uint64_t Request_getUser(T R); 38 | extern const char * Request_getController(T); 39 | extern const char * Request_getId(T); 40 | extern const char * Request_getMethod(T); 41 | extern const char * Request_getArg(T); 42 | extern struct evkeyvalq * Request_getPOST(T); 43 | extern struct evkeyvalq * Request_getGET(T); 44 | 45 | 46 | #undef T 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /src/pop3d.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 3 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 4 | Copyright (C) 2006 Aaron Stone aaron@serendipity.cx 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later 10 | version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | /* 23 | * 24 | * pop3d.c 25 | * 26 | * main prg for pop3 daemon 27 | */ 28 | 29 | #include "dbmail.h" 30 | #define THIS_MODULE "pop3d" 31 | #define PNAME "dbmail/pop3d" 32 | 33 | /* also used in pop3.c */ 34 | int pop_before_smtp = 0; 35 | 36 | int main(int argc, char *argv[]) 37 | { 38 | ServerConfig_T config; 39 | int result; 40 | 41 | openlog(PNAME, LOG_PID, LOG_MAIL); 42 | memset(&config, 0, sizeof(ServerConfig_T)); 43 | result = server_getopt(&config, "POP", argc, argv); 44 | if (result == -1) goto shutdown; 45 | if (result == 1) { 46 | server_showhelp("dbmail-pop3d", 47 | "This daemon provides Post Office Protocol v3 services.\n"); 48 | goto shutdown; 49 | } 50 | config.ClientHandler = pop3_handle_connection; 51 | pop_before_smtp = config.service_before_smtp; 52 | result = server_mainloop(&config, "dbmail-pop3d"); 53 | shutdown: 54 | TRACE(TRACE_INFO, "exit"); 55 | return result; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | DBMail THANKS file 2 | 3 | DBMail has originally been written by Eelco van Beek, Roel Rozendaal 4 | and Ilja Booij. Development since 2.0 is led by Paul J Stevens and 5 | Aaron Stone. 6 | 7 | Special thanks to Metaways.net for providing resources so dbmail runs 8 | on Solaris, and to InternetConnection.net for providing the original 9 | sqlite driver. 10 | 11 | Many people further contributed to DBMail by reporting problems, 12 | suggesting various improvements and submitting code patches. 13 | 14 | Aaron Stone aaron at serendipity dot cx 15 | Alex Wheeler awheeler at royall dot com 16 | Chingson Chen chingson at msquaretech dot com 17 | Christian G Warden xndbmail at xerus dot org 18 | Christian Haugg haugg at gmx dot de 19 | Dan Weber dan at mirrorlynx dot com 20 | Ed K. ed at hp dot uab dot edu 21 | Feargal Reilly feargal at chrysalis dot net 22 | Gary Murphy gmurphy at sf dot net 23 | Geo Carncross geocar at internetconnection dot net 24 | Hans Kristian Rosbach hk at isphuset dot no 25 | Harald Reindl h.reindl at thelounge dot net 26 | Javier Carlos javier at nediam dot com dot mx 27 | Jesse Norrel jesse at kci dot net 28 | Jonathan Feally vulture at netvulture dot com 29 | Leif Jackson ljackson at jjcons dot com 30 | Lars Kneschke l.kneschke at metaways dot net 31 | Lou Picciano loupicciano at comcast dot net 32 | Kaname kaname at conga.jp 33 | Matthew Sayler sayler at speedsite.com 34 | Paul F De La Cruz polito at blackbeanie dot net 35 | Paul J Stevens paul at nfg dot nl 36 | Ryan Butler rbutler at adiis dot net 37 | Ryo HAYAKAWA ryo at fastriver.net 38 | Steven Kroon steven at stevenkroon dot com 39 | Thomas Mueller dbmail at tmueller dot com 40 | Timo Sirainen tss at iki dot fi 41 | 42 | Surely there are errors or forgotten people, but we appreciate you 43 | nonetheless! If you'd like to be added to the list, just let us know. 44 | -------------------------------------------------------------------------------- /sql/mysql/2_3_0-2_3_2.mysql: -------------------------------------------------------------------------------- 1 | 2 | SET FOREIGN_KEY_CHECKS=0; 3 | 4 | DROP TABLE IF EXISTS `dbmail_mimeparts2`; 5 | CREATE TABLE `dbmail_mimeparts2` ( 6 | `id` bigint(21) NOT NULL AUTO_INCREMENT, 7 | `hash` char(128) NOT NULL, 8 | `data` longblob NOT NULL, 9 | `size` bigint(21) NOT NULL, 10 | PRIMARY KEY (`id`), 11 | KEY `hash` (`hash`) 12 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 13 | 14 | DROP TABLE IF EXISTS `dbmail_partlists2`; 15 | CREATE TABLE `dbmail_partlists2` ( 16 | `physmessage_id` bigint(21) NOT NULL, 17 | `is_header` tinyint(1) NOT NULL default '0', 18 | `part_key` smallint(6) NOT NULL default '0', 19 | `part_depth` smallint(6) NOT NULL default '0', 20 | `part_order` smallint(6) NOT NULL default '0', 21 | `part_id` bigint(21) NOT NULL, 22 | KEY `physmessage_id` (`physmessage_id`), 23 | KEY `part_id` (`part_id`), 24 | CONSTRAINT `dbmail_partlists2_ibfk_1` FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, 25 | CONSTRAINT `dbmail_partlists2_ibfk_2` FOREIGN KEY (`part_id`) REFERENCES `dbmail_mimeparts2` (`id`) ON DELETE CASCADE ON UPDATE CASCADE 26 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 27 | 28 | INSERT INTO dbmail_mimeparts2 (hash, data, size) SELECT id, data, size FROM dbmail_mimeparts; 29 | INSERT INTO dbmail_partlists2 ( 30 | physmessage_id, is_header, part_key, part_depth, part_order, part_id 31 | ) SELECT 32 | p.physmessage_id,p.is_header,p.part_key,p.part_depth,p.part_order,m.id FROM dbmail_mimeparts2 m JOIN dbmail_partlists p ON p.part_id=m.hash; 33 | 34 | rename table dbmail_mimeparts to dbmail_mimeparts_old; 35 | rename table dbmail_partlists to dbmail_partlists_old; 36 | rename table dbmail_mimeparts2 to dbmail_mimeparts; 37 | rename table dbmail_partlists2 to dbmail_partlists; 38 | drop table dbmail_mimeparts_old; 39 | drop table dbmail_partlists_old; 40 | 41 | SET FOREIGN_KEY_CHECKS=1; 42 | 43 | -------------------------------------------------------------------------------- /src/imapd.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 3 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 4 | Copyright (C) 2006 Aaron Stone aaron@serendipity.cx 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later 10 | version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | /* 23 | * 24 | * imapd.c 25 | * 26 | * main prg for imap daemon 27 | */ 28 | 29 | #include "dbmail.h" 30 | #define THIS_MODULE "imapd" 31 | #define PNAME "dbmail/imap4d" 32 | 33 | extern int imap_before_smtp; 34 | 35 | int main(int argc, char *argv[]) 36 | { 37 | ServerConfig_T config; 38 | int result; 39 | openlog(PNAME, LOG_PID, LOG_MAIL); 40 | memset(&config, 0, sizeof(ServerConfig_T)); 41 | result = server_getopt(&config, "IMAP", argc, argv); 42 | if (result == -1) goto shutdown; 43 | if (result == 1) { 44 | server_showhelp("dbmail-imapd", 45 | "This daemon provides Internet " 46 | "Message Access Protocol 4.1 " 47 | "services."); 48 | goto shutdown; 49 | } 50 | 51 | config.ClientHandler = imap_handle_connection; 52 | imap_before_smtp = config.service_before_smtp; 53 | result = server_mainloop(&config, "dbmail-imapd"); 54 | shutdown: 55 | TRACE(TRACE_INFO, "return [%d]", result); 56 | return result; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /doc/README.usermap: -------------------------------------------------------------------------------- 1 | 2 | README.usermap 3 | 4 | DBMail supports usermaps and domainmaps which will allow you to map login names to 5 | fully qualified (unique) userids as used in the dbmail_users table or ldap. 6 | 7 | Rationale: 8 | 9 | 1) support 1-1 and 1-N mappings of login usernames to userids 10 | 11 | You can use this during a transition to a new username policy. For instance, 12 | when you want to give all new users their email address as login, but you want 13 | to allow all existing users to login using their old login. 14 | 15 | 2) support IP based virtual hosting 16 | 17 | This means you can use separate namespaces for different IP addresses dbmail 18 | is listening on. 19 | 20 | 21 | The layout of the new dbmail_usermap table is as follows: 22 | 23 | --------------------------- 24 | login | varchar (100) 25 | sock_allow | varchar (100) 26 | sock_deny | varchar (100) 27 | userid | varchar (100) 28 | --------------------------- 29 | 30 | Consider the following settings: 31 | 32 | | login | sock_allow | sock_deny | userid 33 | --+------------+----------------------+----------------------+------------- 34 | 1 |client | | | client@a.com 35 | 2 |client | inet:127.0.0.1:143 | | client@b.com 36 | 3 |client | inet:10.1.1.1:143 | inet:10.1.1.1:110 | client@c.com 37 | 4 |ANY | inet:10.1.1.2:143 | | %s@d.com 38 | 5 |client | | inet:0.0.0.0:0 | 39 | 40 | row 1 will give you a simple 1-1 mapping irrespective of the IP address connected to. 41 | 42 | row 2 will allow client@b.com to login on a single IP address with imap. 43 | 44 | row 3 will allow client@c.com to login on a single IP address with imap but will reject 45 | POP access. 46 | 47 | row 4 will map all logins on a single IP address to an expanded form. 48 | 49 | row 5 will deny any kind of access to client. 50 | 51 | 52 | -------------------------------------------------------------------------------- /sql/mysql/2_2_5-2_3_0.mysql: -------------------------------------------------------------------------------- 1 | SET FOREIGN_KEY_CHECKS=0; 2 | 3 | DROP TABLE IF EXISTS `dbmail_mimeparts`; 4 | CREATE TABLE `dbmail_mimeparts` ( 5 | `id` bigint(21) NOT NULL AUTO_INCREMENT, 6 | `hash` char(128) NOT NULL, 7 | `data` longblob NOT NULL, 8 | `size` bigint(21) NOT NULL, 9 | PRIMARY KEY (`id`), 10 | KEY `hash` (`hash`) 11 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 12 | 13 | DROP TABLE IF EXISTS `dbmail_partlists`; 14 | CREATE TABLE `dbmail_partlists` ( 15 | `physmessage_id` bigint(21) NOT NULL, 16 | `is_header` tinyint(1) NOT NULL default '0', 17 | `part_key` smallint(6) NOT NULL default '0', 18 | `part_depth` smallint(6) NOT NULL default '0', 19 | `part_order` smallint(6) NOT NULL default '0', 20 | `part_id` bigint(21) NOT NULL, 21 | KEY `physmessage_id` (`physmessage_id`), 22 | KEY `part_id` (`part_id`), 23 | CONSTRAINT `dbmail_partlists_ibfk_1` FOREIGN KEY (`physmessage_id`) REFERENCES `dbmail_physmessage` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, 24 | CONSTRAINT `dbmail_partlists_ibfk_2` FOREIGN KEY (`part_id`) REFERENCES `dbmail_mimeparts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE 25 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 26 | 27 | SET FOREIGN_KEY_CHECKS=1; 28 | 29 | ALTER TABLE dbmail_mailboxes ADD mtime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'; 30 | ALTER TABLE dbmail_mailboxes ADD KEY mtime (mtime); 31 | ALTER TABLE dbmail_mailboxes CHANGE name name VARCHAR(255) NOT NULL DEFAULT ''; 32 | 33 | DROP INDEX dbmail_sievescripts_1 ON dbmail_sievescripts; 34 | CREATE UNIQUE INDEX dbmail_sievescripts_1 ON dbmail_sievescripts(owner_idnr, name); 35 | 36 | DROP TABLE IF EXISTS dbmail_keywords; 37 | CREATE TABLE dbmail_keywords ( 38 | message_idnr bigint(21) NOT NULL, 39 | keyword varchar(64) NOT NULL, 40 | PRIMARY KEY (message_idnr,keyword), 41 | CONSTRAINT dbmail_keywords_ibfk_1 FOREIGN KEY (message_idnr) REFERENCES dbmail_messages (message_idnr) ON DELETE CASCADE ON UPDATE CASCADE 42 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 43 | 44 | -------------------------------------------------------------------------------- /sql/postgresql/2_2_5-2_3_0.pgsql: -------------------------------------------------------------------------------- 1 | 2 | DROP INDEX dbmail_sievescripts_1; 3 | CREATE UNIQUE INDEX dbmail_sievescripts_1 ON dbmail_sievescripts(owner_idnr, name); 4 | 5 | CREATE SEQUENCE dbmail_mimeparts_id_seq; 6 | CREATE TABLE dbmail_mimeparts ( 7 | id bigint NOT NULL DEFAULT nextval('dbmail_mimeparts_id_seq'), 8 | hash character(256) NOT NULL, 9 | data bytea NOT NULL, 10 | size bigint NOT NULL, 11 | PRIMARY KEY (id) 12 | ); 13 | 14 | CREATE INDEX dbmail_mimeparts_1 ON dbmail_mimeparts USING btree (hash); 15 | 16 | CREATE TABLE dbmail_partlists ( 17 | physmessage_id bigint NOT NULL, 18 | is_header smallint DEFAULT (0)::smallint NOT NULL, 19 | part_key integer DEFAULT 0 NOT NULL, 20 | part_depth integer DEFAULT 0 NOT NULL, 21 | part_order integer DEFAULT 0 NOT NULL, 22 | part_id bigint NOT NULL 23 | ); 24 | 25 | CREATE INDEX dbmail_partlists_1 ON dbmail_partlists USING btree (physmessage_id); 26 | CREATE INDEX dbmail_partlists_2 ON dbmail_partlists USING btree (part_id); 27 | 28 | ALTER TABLE ONLY dbmail_partlists 29 | ADD CONSTRAINT dbmail_partlists_part_id_fkey FOREIGN KEY (part_id) REFERENCES dbmail_mimeparts(id) ON UPDATE CASCADE ON DELETE CASCADE; 30 | 31 | ALTER TABLE ONLY dbmail_partlists 32 | ADD CONSTRAINT dbmail_partlists_physmessage_id_fkey FOREIGN KEY (physmessage_id) REFERENCES dbmail_physmessage(id) ON UPDATE CASCADE ON DELETE CASCADE; 33 | 34 | ALTER TABLE ONLY dbmail_mailboxes ALTER COLUMN name TYPE VARCHAR(255); 35 | ALTER TABLE ONLY dbmail_mailboxes ADD mtime TIMESTAMP WITHOUT TIME ZONE; 36 | 37 | CREATE TABLE dbmail_keywords ( 38 | message_idnr bigint NOT NULL, 39 | keyword varchar(64) NOT NULL 40 | ); 41 | ALTER TABLE ONLY dbmail_keywords 42 | ADD CONSTRAINT dbmail_keywords_pkey PRIMARY KEY (message_idnr, keyword); 43 | ALTER TABLE ONLY dbmail_keywords 44 | ADD CONSTRAINT dbmail_keywords_fkey FOREIGN KEY (message_idnr) REFERENCES dbmail_messages (message_idnr) ON DELETE CASCADE ON UPDATE CASCADE; 45 | 46 | -------------------------------------------------------------------------------- /src/dm_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2012 NFG Net Facilities Group BV support@nfg.nl 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | /* 22 | * ADT interface for Strings allocated from Memory Pool 23 | * 24 | */ 25 | 26 | 27 | #ifndef DM_STRING_H 28 | #define DM_STRING_H 29 | 30 | #include 31 | #include "dm_mempool.h" 32 | 33 | typedef struct String_T *String_T; 34 | 35 | extern String_T p_string_new(Mempool_T, const char *); 36 | extern String_T p_string_assign(String_T, const char *); 37 | extern void p_string_printf(String_T, const char *, ...); 38 | extern void p_string_append_printf(String_T, const char *, ...); 39 | extern void p_string_append_vprintf(String_T, const char *, va_list); 40 | extern void p_string_append_len(String_T, const char *, size_t); 41 | extern String_T p_string_erase(String_T, size_t, int); 42 | extern String_T p_string_truncate(String_T, size_t); 43 | extern uint64_t p_string_len(String_T); 44 | extern const char * p_string_str(String_T); 45 | extern void p_string_unescape(String_T); 46 | extern char * p_string_free(String_T, gboolean); 47 | 48 | #define p_string_append(S, s) p_string_append_len(S, s, strlen(s)) 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /contrib/startup-scripts/gentoo/init.d-dbmail: -------------------------------------------------------------------------------- 1 | #!/sbin/runscript 2 | # 3 | # chkconfig: - 91 35 4 | # description: Starts and stops the dbmail-lmtpd daemon 5 | # 6 | 7 | # Where are the binaries located? 8 | LMTPD=0 9 | IMAPD=1 10 | POP3D=2 11 | TIMSIEVED=3 12 | DAEMON[$LMTPD]=dbmail-lmtpd 13 | DAEMON[$IMAPD]=dbmail-imapd 14 | DAEMON[$POP3D]=dbmail-pop3d 15 | DAEMON[$TIMSIEVED]=dbmail-timsieved 16 | 17 | BIN_DIR=/usr/sbin 18 | PID_DIR=/var/run 19 | PID=pid 20 | 21 | # Where is the dbmail.conf file located? 22 | CONFIG=/etc/dbmail.conf 23 | 24 | # opts="${opts} reload" 25 | 26 | depend() { 27 | need net 28 | # This won't cause a hard failure if neither is installed, however. 29 | use mysql 30 | use pgsql 31 | after mta 32 | } 33 | 34 | initService() { 35 | # Avoid using root's TMPDIR 36 | unset TMPDIR 37 | 38 | # Check that config file exists. 39 | [ -f $CONFIG ] || exit 0 40 | 41 | RETVAL=0 42 | } 43 | 44 | start() { 45 | initService 46 | 47 | for i in $DAEMONS; do 48 | THISDAEMON=`echo $i | awk '{print toupper($1)}'`; 49 | if [ -n ${DAEMON[$THISDAEMON]} ]; then 50 | # echo $THISDAEMON is ${DAEMON[$THISDAEMON]}; 51 | startfoo ${DAEMON[$THISDAEMON]}; 52 | fi 53 | done 54 | 55 | eend $? 56 | } 57 | 58 | startfoo() { 59 | PROGRAM=$1 60 | ebegin "Starting DBMail daemon ($PROGRAM)" 61 | start-stop-daemon --start --quiet \ 62 | --pidfile $PID_DIR/$PROGRAM.$PID \ 63 | --exec $BIN_DIR/$PROGRAM \ 64 | --name $PROGRAM \ 65 | -- -f $CONFIG -p $PID_DIR/$PROGRAM.$PID 2>&1 66 | eend $? 67 | } 68 | 69 | stopfoo() { 70 | PROGRAM=$1 71 | ebegin "Stopping DBMail daemon ($PROGRAM)" 72 | start-stop-daemon --stop --quiet --retry 15 \ 73 | --pidfile $PID_DIR/$PROGRAM.$PID 74 | eend $? 75 | } 76 | 77 | stop() { 78 | initService 79 | 80 | for i in $DAEMONS; do 81 | THISDAEMON=`echo $i | awk '{print toupper($1)}'`; 82 | if [ -n ${DAEMON[$THISDAEMON]} ]; then 83 | # echo $THISDAEMON is ${DAEMON[$THISDAEMON]}; 84 | stopfoo ${DAEMON[$THISDAEMON]}; 85 | fi 86 | done 87 | 88 | eend $? 89 | } 90 | 91 | -------------------------------------------------------------------------------- /src/httpd.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 3 | Copyright (C) 2006 Aaron Stone aaron@serendipity.cx 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | /* 22 | * 23 | * httpd.c 24 | * 25 | * main prg for http daemon 26 | */ 27 | 28 | #include "dbmail.h" 29 | #include "dm_request.h" 30 | 31 | #define THIS_MODULE "httpd" 32 | #define PNAME "dbmail/httpd" 33 | 34 | int main(int argc, char *argv[]) 35 | { 36 | ServerConfig_T config; 37 | int result; 38 | 39 | g_mime_init(GMIME_ENABLE_RFC2047_WORKAROUNDS); 40 | g_mime_parser_get_type(); 41 | g_mime_stream_get_type(); 42 | g_mime_stream_mem_get_type(); 43 | g_mime_stream_file_get_type(); 44 | g_mime_stream_buffer_get_type(); 45 | g_mime_stream_filter_get_type(); 46 | g_mime_filter_crlf_get_type(); 47 | 48 | openlog(PNAME, LOG_PID, LOG_MAIL); 49 | 50 | memset(&config, 0, sizeof(ServerConfig_T)); 51 | result = server_getopt(&config, "HTTP", argc, argv); 52 | if (result == -1) 53 | goto shutdown; 54 | 55 | if (result == 1) { 56 | server_showhelp("dbmail-httpd", 57 | "This daemon provides HTTP services."); 58 | goto shutdown; 59 | } 60 | 61 | config.cb = Request_cb; 62 | result = server_mainloop(&config, "dbmail-httpd"); 63 | 64 | shutdown: 65 | g_mime_shutdown(); 66 | config_free(); 67 | 68 | TRACE(TRACE_INFO, "exit"); 69 | return result; 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/dm_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 3 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | /* 22 | * list.h: list header */ 23 | 24 | #ifndef DM_LIST_H 25 | #define DM_LIST_H 26 | 27 | #include 28 | #include 29 | #include "dm_mempool.h" 30 | 31 | GList *g_list_slices(GList *list, unsigned limit); 32 | GList *g_list_slices_u64(GList *list, unsigned limit); 33 | GList *g_list_dedup(GList *list, GCompareFunc compare_func, int freeitems); 34 | 35 | GString * g_list_join(GList * list, const gchar * sep); 36 | GString * g_list_join_u64(GList * list, const gchar * sep); 37 | GList * g_list_append_printf(GList * list, const char * format, ...); 38 | 39 | void g_list_destroy(GList *list); 40 | void g_list_merge(GList **a, GList *b, int condition, GCompareFunc func); 41 | 42 | /* 43 | * provide memory pool based list 44 | */ 45 | 46 | #define T List_T 47 | 48 | typedef struct T *T; 49 | 50 | extern T p_list_new(Mempool_T); 51 | extern T p_list_append(T, void *); 52 | extern T p_list_prepend(T, void *); 53 | extern T p_list_last(T); 54 | extern T p_list_first(T); 55 | extern T p_list_previous(T); 56 | extern T p_list_next(T); 57 | extern T p_list_remove(T, T); 58 | extern size_t p_list_length(T); 59 | extern void * p_list_data(T); 60 | extern void p_list_free(T *); 61 | 62 | #undef T 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/timsieved.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2004 Aaron Stone aaron at serendipity dot cx 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | /* 22 | * timsieved.c 23 | * 24 | * main prg for tims daemon 25 | */ 26 | 27 | #include "dbmail.h" 28 | #define THIS_MODULE "timsieved" 29 | #define PNAME "dbmail/timsieved" 30 | 31 | /* this is write-once read-many, so we'll do it once for all children. */ 32 | const char *sieve_extensions = NULL; 33 | 34 | int main(int argc, char *argv[]) 35 | { 36 | ServerConfig_T config; 37 | int result; 38 | 39 | openlog(PNAME, LOG_PID, LOG_MAIL); 40 | 41 | memset(&config, 0, sizeof(ServerConfig_T)); 42 | result = server_getopt(&config, "SIEVE", argc, argv); 43 | if (result == -1) goto shutdown; 44 | if (result == 1) { 45 | server_showhelp("dbmail-timsieved", 46 | "This daemon provides Tim's Sieve Daemon services.\n"); 47 | goto shutdown; 48 | } 49 | 50 | config.ClientHandler = tims_handle_connection; 51 | 52 | /* Get the Sieve capabilities. This may also cause the 53 | * program to bomb out if Sieve support was not compiled in. */ 54 | sieve_extensions = sort_listextensions(); 55 | if (sieve_extensions == NULL) { 56 | fprintf(stderr, "dbmail-timsieved: error loading Sieve extensions.\n\n"); 57 | result = 1; 58 | goto shutdown; 59 | } 60 | result = server_mainloop(&config, "dbmail-timsieved"); 61 | shutdown: 62 | TRACE(TRACE_INFO, "exit"); 63 | return result; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /jenkins/buildout.cfg: -------------------------------------------------------------------------------- 1 | [buildout] 2 | parts = 3 | dbmail 4 | dbmail_conf 5 | supervisor 6 | py 7 | 8 | 9 | [dbmail] 10 | recipe = iw.recipe.cmd 11 | on_install = true 12 | on_update = false 13 | cmds = 14 | (export LD_LIBRARY_PATH=/usr/pgsql-9.2/lib && cd ${buildout:directory}/../ && automake -a && test -f Makefile || ./configure --enable-static=yes --enable-shared=no --with-check --with-sieve --prefix=${buildout:directory} && make install) 15 | 16 | [dbmail_conf] 17 | recipe = iw.recipe.cmd 18 | on_install = true 19 | on_update = true 20 | cmds = 21 | mkdir -p ${buildout:directory}/etc 22 | ${buildout:directory}/sbin/dbmail-users -l 23 | sed -i -e 's/^port.*=.*\<24\>.*/port = 10024/' ${buildout:directory}/etc/dbmail.conf 24 | sed -i -e 's/^port.*=.*\<110\>.*/port = 10110/' ${buildout:directory}/etc/dbmail.conf 25 | sed -i -e 's/^port.*=.*\<143\>.*/port = 10143/' ${buildout:directory}/etc/dbmail.conf 26 | sed -i -e 's,^errorlog.*,errorlog = ${buildout:directory}/var/log/dbmail.err,' ${buildout:directory}/etc/dbmail.conf 27 | sed -i -e 's,^logfile.*,logfile = ${buildout:directory}/var/log/dbmail.log,' ${buildout:directory}/etc/dbmail.conf 28 | sed -i -e 's,^file_logging_levels.*,file_logging_levels = 255,' ${buildout:directory}/etc/dbmail.conf 29 | sed -i -e 's,^pid_directory.*,pid_directory = ${buildout:directory}/var,' ${buildout:directory}/etc/dbmail.conf 30 | sed -i -e 's,^dburi.*,dburi = postgresql://localhost:5432/dbmail?user=dbmail\&password=dbmail,' ${buildout:directory}/etc/dbmail.conf 31 | 32 | [supervisor] 33 | recipe = collective.recipe.supervisor 34 | port = 127.0.0.1:12345 35 | serverurl = http://127.0.0.1:12345 36 | programs = 37 | 10 dbmail-imapd ${buildout:directory}/sbin/dbmail-imapd [-D] true 38 | 10 dbmail-pop3d ${buildout:directory}/sbin/dbmail-pop3d [-D] true 39 | 10 dbmail-lmtpd ${buildout:directory}/sbin/dbmail-lmtpd [-D] true 40 | 10 dbmail-timsieved ${buildout:directory}/sbin/dbmail-timsieved [-D] true 41 | 10 dbmail-httpd ${buildout:directory}/sbin/dbmail-httpd [-D] true 42 | 43 | [py] 44 | recipe = zc.recipe.egg 45 | eggs = pyparsing 46 | interpreter = py 47 | scripts = py 48 | -------------------------------------------------------------------------------- /src/dm_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 3 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | 21 | headers for debug.c 22 | 23 | */ 24 | 25 | #ifndef DM_DEBUG_H 26 | #define DM_DEBUG_H 27 | 28 | #include "dbmail.h" 29 | 30 | typedef enum { 31 | TRACE_EMERG = 1, 32 | TRACE_ALERT = 2, 33 | TRACE_CRIT = 4, 34 | TRACE_ERR = 8, 35 | TRACE_WARNING = 16, 36 | TRACE_NOTICE = 32, 37 | TRACE_INFO = 64, 38 | TRACE_DEBUG = 128, 39 | TRACE_DATABASE = 256 // Logs at Debug Level 40 | } Trace_T; 41 | 42 | 43 | /* Define several macros for GCC specific attributes. 44 | * Although the __attribute__ macro can be easily defined 45 | * to nothing, these macros make them a little prettier. 46 | * */ 47 | #ifdef __GNUC__ 48 | #define UNUSED __attribute__((__unused__)) 49 | #define PRINTF_ARGS(X, Y) __attribute__((format(printf, X, Y))) 50 | #else 51 | #define UNUSED 52 | #define PRINTF_ARGS(X, Y) 53 | #endif 54 | 55 | 56 | #define TRACE(level, fmt...) trace(level, THIS_MODULE, __func__, __LINE__, fmt) 57 | void TabortHandler(const char *error); 58 | void trace(Trace_T level, const char * module, const char * function, int line, const char *formatstring, ...) PRINTF_ARGS(5, 6); 59 | 60 | void configure_debug(const char *service_name, Trace_T trace_syslog, Trace_T trace_stderr); 61 | 62 | void null_logger(const char UNUSED *log_domain, GLogLevelFlags UNUSED log_level, const char UNUSED *message, gpointer UNUSED data); 63 | #endif 64 | -------------------------------------------------------------------------------- /man/dbmail-imapd.txt: -------------------------------------------------------------------------------- 1 | DBMAIL-IMAPD(8) 2 | =============== 3 | 4 | 5 | NAME 6 | ---- 7 | dbmail-imapd - provides access to the DBMail system to clients supporting 8 | Internet Message Access Protocol, IMAP4r1, as specified in RFC 9 | 3501. 10 | 11 | SYNOPSIS 12 | -------- 13 | dbmail-imapd [-f configfile] [-p pidfile] [-nvVh] 14 | 15 | DESCRIPTION 16 | ----------- 17 | The dbmail-imapd daemon is a fully featured IMAP4r1 server. 18 | 19 | include::serveropts.txt[] 20 | 21 | include::commonopts.txt[] 22 | 23 | EXAMPLE 24 | ------- 25 | 26 | For xinetd::: 27 | ----------------------------------------------------------- 28 | # /etc/xinet.d/dbmail-imap 29 | # 30 | service imap 31 | { 32 | socket_type = stream 33 | wait = no 34 | user = root 35 | server = /usr/local/sbin/dbmail-imapd 36 | protocol = tcp 37 | server_args = -n 38 | log_on_failure += USERID 39 | disable = no 40 | } 41 | ----------------------------------------------------------- 42 | 43 | For stunnel::: 44 | ----------------------------------------------------------- 45 | pid = /var/run/stunnel.pid 46 | cert = /etc/stunnel/yourkeys.pem 47 | 48 | # The next two sections will turn stunnel 49 | # into a 'secure inetd'. This is mutually 50 | # exclusive with the proxy sections below. 51 | [dbmail-pop3d] 52 | accept = 995 53 | exec = /usr/local/sbin/dbmail-pop3d 54 | execargs = dbmail-pop3d -n 55 | 56 | [dbmail-imapd] 57 | accept = 993 58 | exec = /usr/local/sbin/dbmail-imapd 59 | execargs = dbmail-imapd -n 60 | 61 | # The next two sections will proxy 62 | # from the secure protocol over to 63 | # the insecure protocol. In this case, 64 | # use BINDIP=localhost in dbmail.conf! 65 | [pop3s] 66 | accept = 995 67 | connect = 110 68 | 69 | [imaps] 70 | accept = 993 71 | connect = 143 72 | 73 | # Useful if your preferred SMTP server doesn't do SSL/TLS. 74 | # This is with your MTA configuration, not DBMail, per se. 75 | [ssmtp] 76 | accept = 465 77 | connect = 25 78 | ----------------------------------------------------------- 79 | 80 | 81 | include::footer.txt[] 82 | -------------------------------------------------------------------------------- /doc/README.qmail: -------------------------------------------------------------------------------- 1 | /* */ 2 | 3 | Using DBMail with QMail 4 | ======================= 5 | 6 | Thanks to Edward Allen for this information. Note that this information 7 | is quite old. If you have more recent information on QMail please join 8 | the dev mailing list or file a bug with the project. 9 | 10 | 11 | 1. Prerequisites 12 | 13 | * A DBMail installation 14 | * A QMail installation 15 | 16 | 2. Add the domain you wish to receive mail for to 17 | /var/qmail/control/rcpthosts. For example, you can add 18 | 19 | example.com 20 | 21 | (yes, only that :) ) to /var/qmail/control/rcpthosts 22 | 23 | 3. Add delivery information to /var/qmail/control/virtualdomains: 24 | 25 | example.com:dbmail 26 | 27 | where 'dbmail' is the dbmail system user you chose. If the file 28 | virtualdomains doesn't exist you have to create it. 29 | 30 | 4. Make sure the file /var/qmail/control/locals exists and is empty. 31 | 32 | 5. Now create a dot-qmail file in the dbmail home directory called 33 | .qmail-default that contains the next single line: 34 | 35 | |/usr/local/sbin/dbmail-deliver -d ${RECIPIENT:7} 36 | 37 | The pipe tells qmail to pipe the email through a command. The 38 | ${RECIPIENT:7} takes the environment variable $RECIPIENT and chops off 39 | the first seven characters. This is needed because the value of 40 | RECIPIENT is dbmail-the_e-mail_address (for example: 41 | dbmail-john@example.com or dbmail-frank@example.com). 42 | 43 | If your dbmail user is not dbmail, you'll need to change the 7 to 44 | the number of characters in your dbmail user's name plus one (the 45 | dash '-' after the dbmail user's name). So, if the dbmail user's 46 | name you chose is joe, your .qmail-default file should contain: 47 | 48 | |/usr/local/sbin/dbmail-deliver -d ${RECIPIENT:4} 49 | 50 | For more information about dot-qmail files please check the 51 | man page of dot-qmail, you can check it online at: 52 | http://www.qmail.org/man/man5/dot-qmail.html. Pay special 53 | attention to the section 'Extension Addresses'. 54 | 55 | 56 | Note: Right now Qmail (the most recent version of Qmail at the time of 57 | this writing is netqmail-1.05) has no support for the protocol LMTP, 58 | so you can't use dbmail-lmtp with Qmail in an "easy" way (as you do 59 | with Postfix). 60 | 61 | -------------------------------------------------------------------------------- /man/dbmail-export.txt: -------------------------------------------------------------------------------- 1 | DBMAIL-EXPORT(8) 2 | ================ 3 | 4 | 5 | NAME 6 | ---- 7 | dbmail-export - export a mailbox from the DBMail mailsystem to mbox format. 8 | 9 | SYNOPSIS 10 | -------- 11 | dbmail-export [-dr] [-u user] [-m mailbox] [-s imap search] [-o outfile|-b basedir] [-f configFile] 12 | 13 | DESCRIPTION 14 | ----------- 15 | The dbmail-export program allows you to export a DBMail mailbox to an 16 | mbox formatted mailbox. 17 | 18 | OPTIONS 19 | ------- 20 | -u user:: 21 | specify the owner of the mailbox you want to export, using wildcards ? and * 22 | to match one or none, or one or more characters in the username, respectively. 23 | 24 | -m mailbox:: 25 | specify the mailbox you want to export. 26 | 27 | -o outfile:: 28 | specify the file into which the exported mail will be saved. 29 | 30 | -b basedir:: 31 | specify the base directory into which the exported mailboxes will be saved. 32 | 33 | -s search:: 34 | use an IMAP SEARCH string to select messages (default: 1:\*) 35 | for example, to export all messages received in May, use: 36 | "1:* SINCE 1-May-2007 BEFORE 1-Jun-2007" 37 | 38 | -d:: 39 | flag exported messages as \\Deleted (use dbmail-util to expunge). 40 | 41 | -r:: 42 | export mailboxes recursively (default: true unless -m option also 43 | specified). 44 | 45 | include::commonopts.txt[] 46 | 47 | EXAMPLES 48 | -------- 49 | 50 | To export and delete all messages belonging to user 'Joe' in mailbox 'Inbox' 51 | more than 30 days old, try this command: 52 | 53 | dbmail-export -u joe -m inbox -o joesinbox.mbox -d -s "1:* BEFORE `date '+%e-%b-%Y' -d '30 days ago'`" 54 | 55 | Note the careful bash quoting and backticks calling the GNU date(1) command. 56 | GNU date(1) has excellent features for retrieving relative dates. If you are 57 | using a different shell, you may need different quotes. Descriptions of 58 | relative dates are not supported by BSD date(1). 59 | 60 | To export all mailboxes named Spam for all users into individual directories 61 | following the pattern SpamDump//Spam, try this command: 62 | 63 | dbmail-export -u \* -m Spam -b SpamDump 64 | 65 | Note the backslash to prevent the shell from expanding the *, as we want that 66 | * to be passed into DBMail for expansion based on the internal user list. 67 | 68 | include::footer.txt[] 69 | -------------------------------------------------------------------------------- /src/mpool/ChangeLog.1: -------------------------------------------------------------------------------- 1 | 2006-05-31 Gray Watson <> 2 | 3 | * Version 2.1.0 released. 4 | 5 | * Added MPOOL_ERROR_PNT_OVER to distinguish between pointer 6 | overwrite and mpool structure overwrite. 7 | 8 | 2005-05-20 Gray Watson <> 9 | 10 | * Version 2.0.0 released. 11 | 12 | * First external publication of library. 13 | 14 | Thu Mar 4 10:14:21 1999 Gray Watson <> 15 | 16 | * Reworked the way the blocks were split up. 17 | 18 | * Removed the round arguments. Not used. 19 | 20 | Wed Mar 3 19:29:38 1999 Gray Watson <> 21 | 22 | * Moved to random(). Fucking rand() was hiding a lot of problems 23 | from me. 24 | 25 | * Added some additional sanity checks in free(). 26 | 27 | * Added mpool_set_max_pages to the library. 28 | 29 | Thu Feb 25 12:41:51 1999 Gray Watson <> 30 | 31 | * Added log_function transaction callback. 32 | 33 | Thu Feb 25 09:53:33 1999 Gray Watson <> 34 | 35 | * Changed the default page size to 16 * getpagesize. 36 | 37 | Wed Feb 24 17:52:52 1999 Gray Watson <> 38 | 39 | * Major reworking of internals to simplify structures. 40 | 41 | Fri Feb 19 12:52:55 1999 Gray Watson <> 42 | 43 | * Made a number of changes to the internals which removed the 44 | addr_to_block as a performance pig. 45 | 46 | Tue Feb 16 21:11:23 1999 Gray Watson <> 47 | 48 | * Added ability for free to look up in the free bit lists for 49 | memory to use. 50 | 51 | * Added mpool_clear. Good idea. 52 | 53 | Thu Feb 11 02:53:45 1999 Gray Watson <> 54 | 55 | * Finally a working version. Looks much better. 56 | 57 | * Added rounding sizes so it will allocate aligned memory. 58 | 59 | * Added minimum size to the mpool_free function to speed it up. 60 | 61 | Wed Feb 10 23:30:48 1999 Gray Watson <> 62 | 63 | * Version 1 with new fine grained memory resolution almost 64 | working. 65 | 66 | Fri May 2 02:26:28 1997 Gray Watson <> 67 | 68 | * Moved to MAP_PRIVATE from MAP_SHARED. 69 | 70 | * Fixed the min/max handling. 71 | 72 | * Added additional info to mpool_stat. 73 | 74 | Thu May 1 16:51:06 1997 Gray Watson <> 75 | 76 | * Added page-size information request. 77 | 78 | * Added better no-memory errors. 79 | 80 | Thu Apr 24 01:58:41 1997 Gray Watson <> 81 | 82 | * Added handling of null for debugging purposes. 83 | 84 | Mon Apr 14 03:31:26 1997 Gray Watson <> 85 | 86 | * Started the mpool routines. 87 | -------------------------------------------------------------------------------- /src/modules/sortnull.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 1999-2004 Aaron Stone aaron at serendipity dot cx 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | 20 | * 21 | * Functions for running user defined sorting rules 22 | * on a message in the temporary store, usually 23 | * just delivering the message to the user's INBOX 24 | * ...unless they have fancy rules defined, that is :-) 25 | * 26 | */ 27 | 28 | #include "dbmail.h" 29 | #define THIS_MODULE "sort" 30 | 31 | const char * sort_listextensions(void) 32 | { 33 | return ""; 34 | } 35 | 36 | SortResult_T *sort_validate(uint64_t user_idnr UNUSED, char *scriptname UNUSED) 37 | { 38 | TRACE(TRACE_WARNING, "SIEVE sorting enabled in DELIVERY section of dbmail.conf," 39 | " but this build of DBMail was statically configured without Sieve."); 40 | return NULL; 41 | } 42 | 43 | SortResult_T *sort_process(uint64_t user_idnr UNUSED, DbmailMessage *message UNUSED, const char *mailbox UNUSED) 44 | { 45 | TRACE(TRACE_WARNING, "SIEVE sorting enabled in DELIVERY section of dbmail.conf," 46 | " but this build of DBMail was statically configured without Sieve."); 47 | return NULL; 48 | } 49 | 50 | /* SORT RESULT INTERFACE */ 51 | 52 | void sort_free_result(SortResult_T *result UNUSED) 53 | { 54 | return; 55 | } 56 | 57 | int sort_get_cancelkeep(SortResult_T *result UNUSED) 58 | { 59 | return 0; 60 | } 61 | 62 | int sort_get_reject(SortResult_T *result UNUSED) 63 | { 64 | return 0; 65 | } 66 | 67 | const char * sort_get_mailbox(SortResult_T *result UNUSED) 68 | { 69 | return ""; 70 | } 71 | 72 | const char * sort_get_errormsg(SortResult_T *result UNUSED) 73 | { 74 | return ""; 75 | } 76 | 77 | int sort_get_error(SortResult_T *result UNUSED) 78 | { 79 | return 0; 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/authmodule.h: -------------------------------------------------------------------------------- 1 | /* Dynamic loading of the authentication backend. 2 | * We use GLib's multiplatform dl() wrapper 3 | * to open up auth_sql.so or auth_ldap.so and 4 | * populate the global 'auth' structure. 5 | * 6 | * (c) 2005 Aaron Stone 7 | */ 8 | 9 | #ifndef DM_AUTHMODULE_H 10 | #define DM_AUTHMODULE_H 11 | 12 | /* Prototypes must match with those in auth.h 13 | * and in the authentication drivers. */ 14 | typedef struct { 15 | int (* connect)(void); 16 | int (* disconnect)(void); 17 | int (* user_exists)(const char *username, uint64_t * user_idnr); 18 | char * (* get_userid)(uint64_t user_idnr); 19 | int (* check_userid)(uint64_t user_idnr); 20 | GList * (* get_known_users)(void); 21 | GList * (* get_known_aliases)(void); 22 | int (* getclientid)(uint64_t user_idnr, uint64_t * client_idnr); 23 | int (* getmaxmailsize)(uint64_t user_idnr, uint64_t * maxmail_size); 24 | char * (* getencryption)(uint64_t user_idnr); 25 | int (* check_user_ext)(const char *username, GList **userids, GList **fwds, int checks); 26 | int (* adduser)(const char *username, const char *password, const char *enctype, 27 | uint64_t clientid, uint64_t maxmail, uint64_t * user_idnr); 28 | int (* delete_user)(const char *username); 29 | int (* change_username)(uint64_t user_idnr, const char *new_name); 30 | int (* change_password)(uint64_t user_idnr, 31 | const char *new_pass, const char *enctype); 32 | int (* change_clientid)(uint64_t user_idnr, uint64_t new_cid); 33 | int (* change_mailboxsize)(uint64_t user_idnr, uint64_t new_size); 34 | int (* validate)(ClientBase_T *ci, const char *username, const char *password, uint64_t * user_idnr); 35 | uint64_t (* md5_validate)(ClientBase_T *ci, char *username, 36 | unsigned char *md5_apop_he, char *apop_stamp); 37 | int (* get_users_from_clientid)(uint64_t client_id, 38 | uint64_t ** user_ids, unsigned *num_users); 39 | char * (* get_deliver_from_alias)(const char *alias); 40 | GList * (* get_user_aliases)(uint64_t user_idnr); 41 | GList * (* get_aliases_ext)(const char *alias); 42 | int (* addalias)(uint64_t user_idnr, const char *alias, uint64_t clientid); 43 | int (* addalias_ext)(const char *alias, const char *deliver_to, 44 | uint64_t clientid); 45 | int (* removealias)(uint64_t user_idnr, const char *alias); 46 | int (* removealias_ext)(const char *alias, const char *deliver_to); 47 | gboolean (*requires_shadow_user)(void); 48 | } auth_func_t; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test-scripts/imap/fetch-body: -------------------------------------------------------------------------------- 1 | 2 | # header and body fetches 3 | ok fetch 1 rfc822.header 4 | * 1 fetch (rfc822.header $hdr1) 5 | ok fetch 1 body.peek[header] 6 | * 1 fetch (body[header] $hdr1) 7 | 8 | ok fetch 1 (flags body.peek[text]) 9 | * 1 fetch (flags () body[text] {{{ 10 | body1 11 | 12 | 13 | }}}) 14 | ok fetch 1 rfc822.text 15 | * 1 fetch (rfc822.text {{{ 16 | body1 17 | 18 | 19 | }}}) 20 | * 1 fetch (flags (\seen)) 21 | 22 | ok fetch 2 (flags body.peek[]) 23 | * 2 fetch (flags () body[] $full2) 24 | ok fetch 2 rfc822 25 | * 2 fetch (rfc822 $full2) 26 | * 2 fetch (flags (\seen)) 27 | 28 | ok fetch 3 (body[]) 29 | * 3 fetch (body[] $full3) 30 | * 3 fetch (flags (\seen)) 31 | ok fetch 4 (body[header]) 32 | * 4 fetch (body[header] $hdr4) 33 | * 4 fetch (flags (\seen)) 34 | 35 | # partial fetches 36 | ok fetch 2 body.peek[text]<0.3> 37 | * 2 fetch (body[text]<0> "bod") 38 | ok fetch 2 body.peek[text]<3.3> 39 | * 2 fetch (body[text]<3> "y22") 40 | 41 | ok fetch 3 body.peek[text]<0.1> 42 | * 3 fetch (body[text]<0> "b") 43 | ok fetch 3 body.peek[text]<5.1> 44 | * 3 fetch (body[text]<5> "3") 45 | ok fetch 3 body.peek[text]<5.2> 46 | * 3 fetch (body[text]<5> ~{{{ 47 | 3 48 | }}}) 49 | ok fetch 3 body.peek[text]<5.3> 50 | * 3 fetch (body[text]<5> ~{{{ 51 | 3 52 | 53 | }}}) 54 | ok fetch 3 body.peek[text]<6.1> 55 | * 3 fetch (body[text]<6> ~{{{ 56 | 57 | }}}) 58 | ok fetch 3 body.peek[text]<6.2> 59 | * 3 fetch (body[text]<6> ~{{{ 60 | 61 | 62 | }}}) 63 | ok fetch 3 body.peek[text]<7.1> 64 | * 3 fetch (body[text]<7> ~{{{ 65 | 66 | 67 | }}}) 68 | 69 | # header fields 70 | ok fetch 1 body.peek[header.fields (from)] 71 | * 1 fetch (body[header.fields (from)] {{{ 72 | From: User1 73 | 74 | 75 | }}}) 76 | 77 | ok fetch 1 (body.peek[header.fields (from)]) 78 | * 1 fetch (body[header.fields (from)] {{{ 79 | From: User1 80 | 81 | 82 | }}}) 83 | 84 | ok fetch 1 body.peek[header.fields (from subject)] 85 | * 1 fetch (body[header.fields (from subject)] {{{ 86 | From: User1 87 | Subject: s1 88 | 89 | 90 | }}}) 91 | 92 | ok fetch 1 body.peek[header.fields.not (date)] 93 | ! 1 fetch (body[header.fields.not (date)] {{{ 94 | From: User1 95 | Date: Sat, 24 Mar 2007 23:00:00 +0200 96 | Subject: s1 97 | 98 | 99 | }}}) 100 | 101 | ok fetch 1 body.peek[header.fields (xyz)] 102 | * 1 fetch (body[header.fields (xyz)] {{{ 103 | 104 | 105 | }}}) 106 | -------------------------------------------------------------------------------- /src/server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 3 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | /* 22 | * server.h 23 | * 24 | * data type defintions & function prototypes for main server program. 25 | */ 26 | 27 | #ifndef DM_SERVER_H 28 | #define DM_SERVER_H 29 | 30 | #include "dbmail.h" 31 | 32 | #define BLOCK(a) \ 33 | { \ 34 | int flags; \ 35 | if ( (flags = fcntl(a, F_GETFL, 0)) < 0) \ 36 | perror("F_GETFL"); \ 37 | flags &= ~O_NONBLOCK; \ 38 | if (fcntl(a, F_SETFL, flags) < 0) \ 39 | perror("F_SETFL"); \ 40 | } 41 | 42 | 43 | #define UNBLOCK(a) \ 44 | { \ 45 | int flags; \ 46 | if ( (flags = fcntl(a, F_GETFL, 0)) < 0) \ 47 | perror("F_GETFL"); \ 48 | flags |= O_NONBLOCK; \ 49 | if (fcntl(a, F_SETFL, flags) < 0) \ 50 | perror("F_SETFL"); \ 51 | } 52 | 53 | int StartCliServer(ServerConfig_T * conf); 54 | int server_run(ServerConfig_T *conf); 55 | 56 | void dm_queue_push(void *cb, void *session, void *data); 57 | void dm_queue_drain(void); 58 | void dm_queue_heartbeat(void); 59 | 60 | void dm_thread_data_push(gpointer session, gpointer cb_enter, gpointer cb_leave, gpointer data); 61 | void dm_thread_data_sendmessage(gpointer data); 62 | 63 | void server_showhelp(const char *service, const char *greeting); 64 | int server_getopt(ServerConfig_T *config, const char *service, int argc, char *argv[]); 65 | int server_mainloop(ServerConfig_T *config, const char *servicename); 66 | pid_t server_daemonize(ServerConfig_T *conf); 67 | void server_http(ServerConfig_T *conf); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /contrib/expiretrash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # copyright 2007, Paul Stevens, NFG 4 | # licence: GPLv2 5 | 6 | export qfile=`tempfile` 7 | 8 | DBNAME="dbmail" 9 | EXDAYS="60" # expire messages in Trash older then EXDAYS days 10 | DRIVER="mysql" # select on of mysql, pgsql, sqlite 11 | 12 | function cleanup() 13 | { 14 | [ -n "$qfile" ] && rm -f $qfile 15 | } 16 | 17 | function abort() 18 | { 19 | msg="$@" 20 | echo "$msg" 21 | cleanup 22 | exit 1 23 | } 24 | 25 | function sql_expire() 26 | { 27 | ival="$1" 28 | case "$DRIVER" in 29 | mysql) 30 | echo "now() - interval $ival day" 31 | ;; 32 | pgsql) 33 | echo "now() - interval '$ival day'" 34 | ;; 35 | sqlite) 36 | echo "datetime('now','-$ival days')" 37 | ;; 38 | esac 39 | 40 | } 41 | 42 | function query() 43 | { 44 | if `test -e "$1"`; then 45 | q=`cat $1` 46 | else 47 | q="$@" 48 | fi 49 | case "$DRIVER" in 50 | mysql) 51 | mysql --batch --skip-column-names -e "$q" $DBNAME 52 | ;; 53 | pgsql) 54 | psql -q -t -c "$q" $DBNAME 55 | ;; 56 | sqlite) 57 | echo $q|sqlite3 -noheader $DBNAME 58 | ;; 59 | esac 60 | } 61 | 62 | function get_TrashIds() 63 | { 64 | cat > $qfile << EOS 65 | 66 | SELECT mailbox_idnr FROM dbmail_mailboxes b 67 | WHERE b.name IN ('Trash','INBOX/Trash') 68 | OR b.name LIKE 'Trash/%' 69 | OR b.name LIKE 'INBOX/Trash/%' 70 | 71 | EOS 72 | query $qfile|xargs -L50|sed -e 's/ /,/g' 73 | } 74 | 75 | function expire_Trash() 76 | { 77 | ids="$1" 78 | [ -n "$ids" ] || return 1 79 | cat > $qfile << EOQ 80 | START TRANSACTION; 81 | UPDATE dbmail_messages m, dbmail_physmessage p 82 | SET m.deleted_flag=1,m.status=2 83 | WHERE m.mailbox_idnr IN ($ids) 84 | AND p.id=m.physmessage_id 85 | AND p.internal_date < ($EXPIRE); 86 | COMMIT; 87 | EOQ 88 | query $qfile 89 | } 90 | 91 | function main() 92 | { 93 | trap cleanup KILL INT CHLD 94 | export EXPIRE=`sql_expire $EXDAYS` 95 | for l in `get_TrashIds`; do 96 | expire_Trash "$l" 97 | done 98 | cleanup 99 | } 100 | 101 | ## run some tests 102 | realdriver="$DRIVER" 103 | export DRIVER="mysql" 104 | r=`sql_expire "60"` 105 | [ "$r" = "now() - interval 60 day" ] || abort "test failed" 106 | export DRIVER="pgsql" 107 | r=`sql_expire "60"` 108 | [ "$r" = "now() - interval '60 day'" ] || abort "test failed" 109 | export DRIVER="sqlite" 110 | r=`sql_expire "60"` 111 | [ "$r" = "datetime('now','-60 days')" ] || abort "test failed" 112 | 113 | export DRIVER=$realdriver 114 | 115 | main 116 | 117 | -------------------------------------------------------------------------------- /src/dm_mailbox.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | 4 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 5 | 6 | This program is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either 9 | version 2 of the License, or (at your option) any later 10 | version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | 21 | * 22 | * 23 | */ 24 | 25 | /* 26 | * 27 | * \brief DbmailMailbox class 28 | * 29 | */ 30 | 31 | #ifndef DM_MAILBOX_H 32 | #define DM_MAILBOX_H 33 | 34 | #include "dbmail.h" 35 | #include "dm_mailboxstate.h" 36 | 37 | typedef struct { 38 | Mempool_T pool; 39 | gboolean freepool; 40 | 41 | uint64_t id; 42 | uint64_t owner_id; 43 | uint64_t size; 44 | gboolean uid; 45 | uint64_t modseq; 46 | bool condstore; 47 | bool qresync; 48 | 49 | MailboxState_T mbstate; // cache mailbox metadata; 50 | 51 | GList *sorted; // ordered list of UID values 52 | GTree *found; // search result (key: uid, value: msn) 53 | GNode *search; 54 | const char *charset; // charset used during search/sort 55 | 56 | } DbmailMailbox; 57 | 58 | 59 | DbmailMailbox * dbmail_mailbox_new(Mempool_T, uint64_t); 60 | int dbmail_mailbox_open(DbmailMailbox *self); 61 | int dbmail_mailbox_sort(DbmailMailbox *self); 62 | int dbmail_mailbox_search(DbmailMailbox *self); 63 | 64 | GTree * dbmail_mailbox_get_msginfo(DbmailMailbox *self); 65 | 66 | uint64_t dbmail_mailbox_get_id(DbmailMailbox *self); 67 | 68 | void dbmail_mailbox_set_uid(DbmailMailbox *self, gboolean uid); 69 | gboolean dbmail_mailbox_get_uid(DbmailMailbox *self); 70 | 71 | int dbmail_mailbox_dump(DbmailMailbox *self, FILE *ostream); 72 | 73 | void dbmail_mailbox_free(DbmailMailbox *self); 74 | 75 | char * dbmail_mailbox_ids_as_string(DbmailMailbox *self, gboolean uid, const char *sep); 76 | char * dbmail_mailbox_sorted_as_string(DbmailMailbox *self); 77 | char * dbmail_mailbox_orderedsubject(DbmailMailbox *self); 78 | 79 | int dbmail_mailbox_build_imap_search(DbmailMailbox *self, String_T *search_keys, uint64_t *idx, search_order order); 80 | 81 | GTree * dbmail_mailbox_get_set(DbmailMailbox *self, const char *set, gboolean uid); 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 2 | # Copyright (C) 2004-2013 NFG Net Facilities Group support@nfg.nl 3 | 4 | AC_INIT([dbmail], [3.2.0], [dbmail@dbmail.org]) 5 | AC_CONFIG_AUX_DIR(config) 6 | AM_CONFIG_HEADER(config.h:config.in) 7 | AC_CONFIG_MACRO_DIR([m4]) 8 | 9 | # --------------------------------------------- 10 | DM_MSG_CONFIGURE_START 11 | AM_INIT_AUTOMAKE 12 | AM_MAINTAINER_MODE 13 | AC_DEFINE(_GNU_SOURCE,'TRUE','Defined GNU SOURCE') 14 | 15 | # --------------------------------------------- 16 | # shared or static 17 | # --------------------------------------------- 18 | AM_ENABLE_SHARED(no) 19 | AM_ENABLE_STATIC(no) 20 | DM_SET_SHARED_OR_STATIC 21 | AM_CONDITIONAL(SHARED, [ test "$enable_shared" = "yes" ]) 22 | AM_CONDITIONAL(STATIC, [ test "$enable_static" = "yes" ]) 23 | 24 | # --------------------------------------------- 25 | DM_DEFINES 26 | DM_LDAP_CONF 27 | DM_SIEVE_CONF 28 | DM_CHECK_GLIB 29 | DM_CHECK_GMIME 30 | DM_CHECK_MATH 31 | DM_CHECK_MHASH 32 | DM_CHECK_EVENT 33 | DM_CHECK_SSL 34 | DM_CHECK_ZDB 35 | DM_CHECK_JEMALLOC 36 | DM_PATH_CHECK 37 | gl_GETOPT 38 | CMU_SOCKETS 39 | 40 | AM_CONDITIONAL(USE_DM_GETOPT, [test -n "$USE_DM_GETOPT"]) 41 | AM_CONDITIONAL(WITHCHECK, [test -n "$CHECK_LIBS"]) 42 | 43 | AC_ARG_ENABLE([manpages], 44 | AS_HELP_STRING([--enable-manpages], [Enable building and installation of man pages])) 45 | AM_CONDITIONAL(MANPAGES, [ test "$enable_manpages" = "yes" ]) 46 | 47 | AC_ARG_ENABLE([systemd], 48 | AS_HELP_STRING([--enable-systemd], [Enable systemd support])) 49 | AM_CONDITIONAL(SYSTEMD, [ test "$enable_systemd" = "yes" ]) 50 | if [ test "$enable_systemd" = "yes" ]; then 51 | DM_CHECK_SYSTEMD 52 | fi 53 | 54 | AC_PROG_CC 55 | AC_COMPILE_WARNINGS 56 | AC_C_CONST 57 | AC_C_INLINE 58 | AM_CONDITIONAL(SIEVE, [test -n "$SIEVELIB"]) 59 | AM_CONDITIONAL(LDAP, [test -n "$LDAPLIB"]) 60 | AC_C_BIGENDIAN 61 | AC_CHECK_HEADERS(endian.h) 62 | AC_CHECK_HEADERS(crypt.h) 63 | AC_CHECK_LIB(crypt, crypt, [ CRYPTLIB="-lcrypt" ]) 64 | 65 | DM_SET_SQLITECREATE 66 | AC_SUBST(SQLITECREATE) 67 | 68 | DM_UPGRADE_STEPS 69 | 70 | DM_SET_DEFAULT_CONFIGURATION 71 | AC_SUBST(DM_DEFAULT_CONFIGURATION) 72 | 73 | AC_SUBST(CRYPTLIB) 74 | AC_SUBST(SIEVEINC) 75 | AC_SUBST(SIEVELIB) 76 | AC_SUBST(SORTALIB) 77 | AC_SUBST(SORTLTLIB) 78 | AC_SUBST(AUTHALIB) 79 | AC_SUBST(AUTHLTLIB) 80 | AC_SUBST(LDAPLIB) 81 | AC_SUBST(LDAPINC) 82 | AC_SUBST(SOCKETLIB) 83 | AC_SUBST(DM_LOGDIR) 84 | AC_SUBST(DM_CONFDIR) 85 | AC_SUBST(DM_STATEDIR) 86 | AC_SUBST(DM_PKGLIBDIR) 87 | AC_SUBST(CHECK_LIBS) 88 | AC_SUBST(DM_PWD) 89 | AC_PROG_LIBTOOL 90 | 91 | AC_OUTPUT(src/dbmail.h Makefile src/Makefile src/modules/Makefile man/Makefile test/Makefile systemd/Makefile) 92 | 93 | DM_MSG_CONFIGURE_RESULTS 94 | -------------------------------------------------------------------------------- /test-scripts/imap/list: -------------------------------------------------------------------------------- 1 | connections: 3 2 | state: auth 3 | 4 | # get the separator 5 | 1 ok list "" "" 6 | * list () $sep $root 7 | # it should be \noselect, but don't fail everything if it doesn't exist 8 | * list (\noselect) $sep $root 9 | 10 | 1 ok create $mailbox${sep} 11 | 1 ok create $mailbox${sep}test 12 | 2 ok list "" $mailbox${sep}% 13 | * list () $sep $mailbox${sep}test 14 | 15 | 2 ok create $mailbox${sep}test2 16 | 1 ok list "" $mailbox${sep}% 17 | * list () $sep $mailbox${sep}test 18 | * list () $sep $mailbox${sep}test2 19 | 20 | 3 ok create $mailbox${sep}test3${sep} 21 | 2 ok create $mailbox${sep}test3${sep}test4${sep} 22 | 2 ok create $mailbox${sep}test3${sep}test4${sep}test5 23 | 2 ok list "" $mailbox${sep}% 24 | * list () $sep $mailbox${sep}test 25 | * list () $sep $mailbox${sep}test2 26 | * list () $sep $mailbox${sep}test3 27 | ! list () $sep $mailbox${sep}test3${sep}test4 28 | ! list () $sep $mailbox${sep}test3${sep}test4${sep}test5 29 | 30 | 3 ok list "" $mailbox${sep}% 31 | * list () $sep $mailbox${sep}test 32 | * list () $sep $mailbox${sep}test2 33 | * list () $sep $mailbox${sep}test3 34 | 35 | 2 ok list "" $mailbox${sep}%${sep}% 36 | ! list () $sep $mailbox${sep}test 37 | ! list () $sep $mailbox${sep}test2 38 | ! list () $sep $mailbox${sep}test3 39 | * list () $sep $mailbox${sep}test3${sep}test4 40 | ! list () $sep $mailbox${sep}test3${sep}test4${sep}test5 41 | 42 | 3 ok list "" $mailbox${sep}* 43 | * list () $sep $mailbox${sep}test 44 | * list () $sep $mailbox${sep}test2 45 | * list () $sep $mailbox${sep}test3 46 | * list () $sep $mailbox${sep}test3${sep}test4${sep}test5 47 | 48 | 3 ok list $mailbox${sep} * 49 | * list () $sep $mailbox${sep}test 50 | * list () $sep $mailbox${sep}test2 51 | * list () $sep $mailbox${sep}test3 52 | * list () $sep $mailbox${sep}test3${sep}test4${sep}test5 53 | 54 | 2 ok list "" $mailbox${sep}*test4 55 | ! list () $sep $mailbox${sep}test 56 | ! list () $sep $mailbox${sep}test2 57 | ! list () $sep $mailbox${sep}test3 58 | * list () $sep $mailbox${sep}test3${sep}test4 59 | ! list () $sep $mailbox${sep}test3${sep}test4${sep}test5 60 | 61 | 2 ok list "" $mailbox${sep}*test* 62 | * list () $sep $mailbox${sep}test 63 | * list () $sep $mailbox${sep}test2 64 | * list () $sep $mailbox${sep}test3 65 | * list () $sep $mailbox${sep}test3${sep}test4${sep}test5 66 | 67 | 2 ok list "" $mailbox${sep}%3${sep}% 68 | * list () $sep $mailbox${sep}test3${sep}test4 69 | 2 ok list "" $mailbox${sep}%3${sep}%4 70 | * list () $sep $mailbox${sep}test3${sep}test4 71 | 2 ok list "" $mailbox${sep}%t*4 72 | * list () $sep $mailbox${sep}test3${sep}test4 73 | 74 | 2 ok delete $mailbox${sep}test2 75 | 1 ok list "" $mailbox${sep}* 76 | ! list () $sep $mailbox${sep}test2 77 | 78 | 1 ok list "" INBOX 79 | * list () $inboxsep INBOX 80 | -------------------------------------------------------------------------------- /systemd/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 2 | # Copyright (c) 2004-2011 NFG Net Facilities Group BV support@nfg.nl 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU General Public License 6 | # as published by the Free Software Foundation; either 7 | # version 2 of the License, or (at your option) any later 8 | # version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program; if not, write to the Free Software 17 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | 20 | EXTRA_DIST = dbmail-imapd.service.in dbmail-lmtpd.service.in dbmail-pop3d.service.in dbmail-timsieved.service.in 21 | SYSTEMD_UNIT_DIR = /usr/lib/systemd/system 22 | SYSTEMD_TMPFILES_DIR = /usr/lib/tmpfiles.d 23 | PID_DIR=/run/dbmail 24 | 25 | if SYSTEMD 26 | install-systemd: dbmail-imapd.service dbmail-lmtpd.service dbmail-pop3d.service dbmail-timsieved.service dbmail.tmpfiles 27 | $(MKDIR_P) $(DESTDIR)$(SYSTEMD_UNIT_DIR) 28 | $(INSTALL_DATA) dbmail-imapd.service \ 29 | $(DESTDIR)$(SYSTEMD_UNIT_DIR)/dbmail-imapd.service 30 | $(INSTALL_DATA) dbmail-lmtpd.service \ 31 | $(DESTDIR)$(SYSTEMD_UNIT_DIR)/dbmail-lmtpd.service 32 | $(INSTALL_DATA) dbmail-pop3d.service \ 33 | $(DESTDIR)$(SYSTEMD_UNIT_DIR)/dbmail-pop3d.service 34 | $(INSTALL_DATA) dbmail-timsieved.service \ 35 | $(DESTDIR)$(SYSTEMD_UNIT_DIR)/dbmail-timsieved.service 36 | $(MKDIR_P) $(DESTDIR)$(SYSTEMD_TMPFILES_DIR) 37 | $(INSTALL_DATA) dbmail.tmpfiles \ 38 | $(DESTDIR)$(SYSTEMD_TMPFILES_DIR)/dbmail.conf 39 | 40 | uninstall-systemd: 41 | rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/dbmail-imapd.service 42 | rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/dbmail-lmtpd.service 43 | rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/dbmail-pop3d.service 44 | rm -f $(DESTDIR)$(SYSTEMD_UNIT_DIR)/dbmail-timsieved.service 45 | rm -f $(DESTDIR)$(SYSTEMD_TMPFILES_DIR)/dbmail.tmpfiles 46 | rmdir $(DESTDIR)$(SYSTEMD_UNIT_DIR) ||: 47 | 48 | SUFFIXES=.service.in .service .tmpfiles.in .tmpfiles 49 | 50 | .service.in.service: 51 | $(AM_V_GEN)sed \ 52 | -e 's|[@]sbindir[@]|$(sbindir)|g' \ 53 | < $< > $@-t && \ 54 | mv $@-t $@ 55 | 56 | .tmpfiles.in.tmpfiles: 57 | $(AM_V_GEN)sed \ 58 | -e 's|[@]piddir[@]|$(PID_DIR)|g' \ 59 | < $< > $@-t && \ 60 | mv $@-t $@ 61 | 62 | else 63 | install-systemd: 64 | uninstall-systemd: 65 | endif 66 | 67 | install-data-local: install-systemd 68 | uninstall-local: uninstall-systemd 69 | -------------------------------------------------------------------------------- /src/dm_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later 8 | version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | 19 | */ 20 | #ifndef DM_CONFIG_H 21 | #define DM_CONFIG_H 22 | 23 | 24 | /* 25 | * determine the default configuration filename 26 | * may be overridden by a -f switch 27 | */ 28 | void config_get_file(void); 29 | 30 | /** 31 | * \brief read configuration from filename 32 | * \param cfilename name of configuration file 33 | * \return 34 | * - -1 on error 35 | * - 0 on success 36 | */ 37 | int config_read(const char *config_filename); 38 | 39 | /** 40 | * free all memory taken up by config. 41 | */ 42 | void config_free(void); 43 | 44 | /** 45 | * \brief get configuration value for an item 46 | * \param name name of configuration item 47 | * \param service_name name of service 48 | * \param value value of configuration item name 49 | * \return 0 50 | * \attention value is set to a string beginning with a '\\0' 51 | * if no configuration item with name is found in items. 52 | */ 53 | int config_get_value(const Field_T name, const char *service_name, 54 | /*@out@*/ Field_T value); 55 | 56 | /* some common used functions reading config options */ 57 | /** 58 | \brief get parameters for database connection 59 | */ 60 | void GetDBParams(void); 61 | /** 62 | \brief set the overall trace level, using the value in cfg_items 63 | \param service_name name of service to get trace level for. 64 | \attention trace level is set to TRACE_ERR if no trace level value is found 65 | * for service. 66 | */ 67 | void SetTraceLevel(const char *service_name); 68 | 69 | 70 | void pidfile_create(const char *pidFile, pid_t pid); 71 | 72 | void config_get_timeout(ServerConfig_T *config, const char * const service); 73 | void config_get_logfiles(ServerConfig_T *config, const char * const service); 74 | void config_get_security_actions(ServerConfig_T *config); 75 | 76 | char * config_get_pidfile(ServerConfig_T *config, const char *name); 77 | char * config_get_statefile(ServerConfig_T *config, const char *name); 78 | 79 | 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /test/check_dbmail_util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2012 NFG Net Facilities Group BV support@nfg.nl 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later 8 | * version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | * 25 | * Basic unit-test framework for dbmail (www.dbmail.org) 26 | * 27 | * See http://check.sf.net for details and docs. 28 | * 29 | * 30 | * Run 'make check' to see some action. 31 | * 32 | */ 33 | 34 | #include 35 | #include "check_dbmail.h" 36 | 37 | extern char configFile[PATH_MAX]; 38 | 39 | /* 40 | * 41 | * the test fixtures 42 | * 43 | */ 44 | void setup(void) 45 | { 46 | config_get_file(); 47 | config_read(configFile); 48 | configure_debug(NULL,255,0); 49 | GetDBParams(); 50 | db_connect(); 51 | auth_connect(); 52 | } 53 | 54 | void teardown(void) 55 | { 56 | db_disconnect(); 57 | } 58 | START_TEST(test_allocate) 59 | { 60 | uint64_t i = 200000; 61 | GList *l = NULL; 62 | uint64_t *id; 63 | uint64_t *rows = g_new0(uint64_t, i); 64 | g_free(rows); 65 | 66 | while (i-- > 0) { 67 | id = g_new0(uint64_t, 1); 68 | *id = i; 69 | l = g_list_prepend(l, id); 70 | } 71 | g_list_destroy(l); 72 | } 73 | END_TEST 74 | 75 | START_TEST(test_db_icheck_envelope) 76 | { 77 | GList *lost = NULL; 78 | fail_unless(0==db_icheck_envelope(&lost),"db_icheck_envelope failed"); 79 | } 80 | END_TEST 81 | 82 | 83 | Suite *dbmail_common_suite(void) 84 | { 85 | Suite *s = suite_create("Dbmail Util"); 86 | TCase *tc_util = tcase_create("Util"); 87 | 88 | suite_add_tcase(s, tc_util); 89 | 90 | tcase_add_checked_fixture(tc_util, setup, teardown); 91 | tcase_add_test(tc_util, test_allocate); 92 | tcase_add_test(tc_util, test_db_icheck_envelope); 93 | 94 | return s; 95 | } 96 | 97 | int main(void) 98 | { 99 | int nf; 100 | Suite *s = dbmail_common_suite(); 101 | SRunner *sr = srunner_create(s); 102 | srunner_run_all(sr, CK_NORMAL); 103 | nf = srunner_ntests_failed(sr); 104 | srunner_free(sr); 105 | return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 106 | } 107 | 108 | 109 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > 2 | > (c) 2004-2014 NFG Net Facilities Group BV, The Netherlands, support@nfg.nl 3 | > 4 | > (c) 2000-2005 IC&S, The Netherlands 5 | > 6 | 7 | What is it? 8 | =========== 9 | 10 | DBMail is a collection of programs that enables email to be stored in and 11 | retrieved from a database. 12 | 13 | Read the INSTALL file for installation of DBMail. 14 | 15 | Why is it useful? 16 | ================== 17 | 18 | - it enables you to create mailboxes without the need of systemusers. 19 | 20 | - mail is more effeciently stored and therefore it can be inserted an 21 | retrieved much faster dan any regular system (DBMail is currently able to 22 | retrieve aprox. 250 mail messages per second) 23 | 24 | - It's scalable. You can run the dbmail programs on different servers 25 | talking to the same database(cluster). 26 | 27 | - It is more secure. There's no need to maintain system users or write to 28 | the filesystem. All this is done through the database. 29 | 30 | 31 | Who created it? 32 | =============== 33 | 34 | Eelco van Beek at first created a very sloppy version of 35 | this program which didn't work at all. 36 | 37 | Because the DBMail mailing system is big he needed help. 38 | So he asked Roel , one of the people working with him 39 | at IC&S, to join in developing DBMail further. 40 | 41 | In 2003 Ilja Booij joined IC&S to work on the 2.x version. During that time, 42 | Paul Stevens at NFG also joined the development team, initially to provide 43 | debian packaging, later to take over development of the 2.1 release. Aaron 44 | Stone also deserves special thanks for initiating the LDAP driver, maintaining 45 | the delivery chain and of course sieve support. 46 | 47 | DBMail is now a community effort to create a fast, effecient and scalable 48 | database driven mailingsystem. Both IC&S and NFG are fully behind 49 | opensource and the GPL. Therefore DBMail has the GPL licence. 50 | 51 | Both IC&S and NFG provide commercial support and consultancy for this 52 | product. For more information about this you can send an email to 53 | info@ic-s.nl and/or support@nfg.nl. 54 | 55 | > 56 | > Disclaimer: IC&S nor NFG are responsible for any damages resulting from use 57 | > of this software. 58 | > 59 | 60 | It should work with almost no problem. We have clients that run dbmail 61 | with more than 25.000 useraccounts. The system is stable. 62 | 63 | How do i install it? 64 | ==================== 65 | 66 | Check the different README files and the wiki pages on dbmail.org for detailed 67 | information and howtos. 68 | 69 | Future 70 | ====== 71 | 72 | Check the website for further DBMail plans. 73 | 74 | What kind of licence is DBMail? 75 | =============================== 76 | 77 | DBMail uses the GPL version 2 licence. 78 | 79 | It's included in the COPYING file. 80 | ------------------------------------------- 81 | 82 | -------------------------------------------------------------------------------- /src/dm_digest.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either 7 | version 2 of the License, or (at your option) any later 8 | version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "dbmail.h" 21 | #define THIS_MODULE "digest" 22 | 23 | 24 | static const char hex[] = "0123456789abcdef"; 25 | 26 | int dm_digest(const unsigned char * hash, hashid type, char *out) 27 | { 28 | char *buf = out; 29 | size_t i, j; 30 | 31 | for (i = 0; i < mhash_get_block_size(type); i++) { 32 | j = i; 33 | if (type == MHASH_TIGER) { 34 | /* compensate for endian-ess */ 35 | if (i<8) j=7-i; 36 | else if (i<16) j=23-i; 37 | else j=39-i; 38 | } 39 | unsigned int val = hash[j]; 40 | *buf++ = hex[val >> 4]; 41 | *buf++ = hex[val & 0xf]; 42 | } 43 | *buf = '\0'; 44 | 45 | return 0; 46 | } 47 | 48 | static void dm_hash(const unsigned char * buf, hashid type, gpointer data) 49 | { 50 | MHASH td = mhash_init(type); 51 | mhash(td, buf, strlen((const char *)buf)); 52 | mhash_deinit(td, data); 53 | } 54 | 55 | #define DM_HASH(x, t, out) \ 56 | g_return_val_if_fail(x != NULL, 1); \ 57 | unsigned char h[1024]; \ 58 | memset(h,'\0', sizeof(h)); \ 59 | dm_hash((unsigned char *)x, t, (gpointer)h); \ 60 | return dm_digest(h, t, out) 61 | 62 | int dm_whirlpool(const char * const s, char *out) 63 | { 64 | DM_HASH(s, MHASH_WHIRLPOOL, out); 65 | } 66 | 67 | int dm_sha512(const char * const s, char *out) 68 | { 69 | DM_HASH(s, MHASH_SHA512, out); 70 | } 71 | 72 | int dm_sha256(const char * const s, char *out) 73 | { 74 | DM_HASH(s, MHASH_SHA256, out); 75 | } 76 | 77 | int dm_sha1(const char * const s, char *out) 78 | { 79 | DM_HASH(s, MHASH_SHA1, out); 80 | } 81 | 82 | int dm_tiger(const char * const s, char *out) 83 | { 84 | DM_HASH(s, MHASH_TIGER, out); 85 | } 86 | 87 | int dm_md5(const char * const s, char *out) 88 | { 89 | DM_HASH(s, MHASH_MD5, out); 90 | } 91 | 92 | int dm_md5_base64(const char * const s, char *out) 93 | { 94 | char *enc; 95 | g_return_val_if_fail(s != NULL, 1); 96 | unsigned char h[2048]; 97 | memset(h,'\0', sizeof(h)); 98 | dm_hash((unsigned char *)s, MHASH_MD5, h); 99 | enc = g_base64_encode(h, sizeof(h)); 100 | g_strlcpy(out, enc, FIELDSIZE); 101 | return 0; 102 | } 103 | 104 | -------------------------------------------------------------------------------- /contrib/autosubscribe/autosubscribe.sql: -------------------------------------------------------------------------------- 1 | 2 | --- 3 | --- set of triggers and functions to automatically subscribe 4 | --- all normal users to newly created public mailboxes 5 | --- 6 | 7 | 8 | --- 9 | --- list all user/mailboxes combinations for mailboxes 10 | --- owner by __public__ 11 | --- 12 | drop view if exists public_mailbox_users; 13 | create view public_mailbox_users (user_id, mailbox_id) as 14 | select u.user_idnr,b.mailbox_idnr from dbmail_mailboxes b 15 | right outer join dbmail_users u on b.owner_idnr!=u.user_idnr 16 | where 17 | userid not in ('__@!internal_delivery_user!@__','anyone','__public__') and 18 | owner_idnr=(select user_idnr from dbmail_users where userid='__public__'); 19 | 20 | 21 | --- 22 | --- insert a subscription 23 | --- emulates replace into 24 | --- 25 | drop function if exists resubscribe(integer, integer); 26 | create function resubscribe(integer, integer) returns void as $$ 27 | begin 28 | raise info 'resubscribe mailbox user: %, mailbox:% ...', $1, $2; 29 | if not exists(select * from dbmail_subscription where user_id=$1 and mailbox_id=$2) then 30 | raise info 'insert into dbmail_subscription (user_id, mailbox_id) values (%,%)', $1, $2; 31 | insert into dbmail_subscription (user_id, mailbox_id) values ($1, $2); 32 | end if; 33 | return ; 34 | end; 35 | $$ language plpgsql; 36 | 37 | 38 | --- 39 | --- insert acl 40 | --- emulates replace into 41 | --- 42 | drop function if exists autogrant(integer, integer); 43 | create function autogrant(integer, integer) returns void as $$ 44 | begin 45 | if not exists(select * from dbmail_acl where user_id=$2 and mailbox_id=$1) then 46 | raise info 'grant all on mailbox: % to %', $1,$2; 47 | insert into dbmail_acl ( 48 | user_id,mailbox_id,lookup_flag,read_flag,seen_flag, 49 | write_flag,insert_flag,post_flag,create_flag, 50 | delete_flag,deleted_flag,expunge_flag,administer_flag) values ($2,$1, 1,1,1,1,1,1,1,1,1,1,1); 51 | end if; 52 | return; 53 | end; 54 | $$ language plpgsql; 55 | 56 | 57 | --- 58 | --- trigger function for subscribing all users to a public 59 | --- mailboxes and granting the anyone user access to them 60 | --- 61 | drop function if exists auto_subscriber() cascade; 62 | create function auto_subscriber() returns trigger as $$ 63 | declare 64 | prow RECORD; 65 | anyoneid INTEGER; 66 | begin 67 | anyoneid := user_idnr from dbmail_users where userid='anyone'; 68 | for prow in select * from public_mailbox_users loop 69 | raise info 'resubscribe mailbox %,% ...', prow.user_id, prow.mailbox_id; 70 | execute 'select resubscribe(' || prow.user_id || ',' || prow.mailbox_id || ')'; 71 | raise info 'grant public access on mailbox % ...', prow.mailbox_id; 72 | execute 'select autogrant(' || prow.mailbox_id || ',' || anyoneid ||')'; 73 | end loop; 74 | return NEW; 75 | end; 76 | $$ language plpgsql; 77 | 78 | --- 79 | --- hook up the trigger 80 | --- 81 | create trigger auto_subscribe_trigger after insert 82 | on dbmail_mailboxes 83 | for each row execute procedure auto_subscriber(); 84 | 85 | 86 | -------------------------------------------------------------------------------- /doc/README.security-password: -------------------------------------------------------------------------------- 1 | 2 | Security Password 3 | ================= 4 | 5 | DBMail now supports a special, separate password. 6 | 7 | This separate password allows you to specify behavior when users log into one 8 | of the DBMail servers using this password. 9 | 10 | The use-case for this feature is when you want to provide your users with an 11 | unobtrusive way to delete all sensitive messages from their accounts, even when 12 | under duress or active observation. When a lot of messages are affected the 13 | login delay will be somewhat greater, but other than that, it is impossible to 14 | tell that anything out of the ordinary has happpened. 15 | 16 | Changes 17 | ------- 18 | 19 | A small schema-migration is required and provided in 20 | sql/DRIVER/upgrades/31202.xxx. If you run a version prior to 3.2.0 you will 21 | have to apply it manually. 22 | 23 | The password can be specified with the --security-password argument of 24 | dbmail-users. The same encryption as for the regular password is used. 25 | 26 | The behavior after logging in using this password can be set per user using the 27 | --security-action argument of dbmail-users. Currently two actions are 28 | hard-coded, but you can expand them as needed. 29 | 30 | Security-action: 31 | ---------------- 32 | 33 | 0: do nothing. This is also the default behavior. 34 | 1: delete everything. In this case all mailboxes owned by the authenticated 35 | user are deleted immediately and irretrievably. 36 | 2 and higher: these can be configured through the security_action setting 37 | in dbmail.conf: 38 | 39 | The first two are hard-coded, as said. It is not possible to override them in 40 | dbmail.conf. Trying to do so will invalidate the entry in dbmail.conf. 41 | 42 | An example: 43 | 44 | security_action = 2:\Deleted;3:\Flagged \Deleted Important $Important 45 | 46 | In this case two additional behaviors are defined. When a user has 47 | security-action 2, and logs on using the security-password all messages that 48 | have the \Deleted system-flag set are queued for later deletion by dbmail-util, 49 | and are immediately inaccessible to the user. 50 | 51 | For users with security-action 3, all messages that have the \Flagged or 52 | \Deleted system flags, or have a user labels 'Important' or '$Important' are 53 | queued for deletion and are also immediately inaccessible to the user. 54 | 55 | Please Note: 56 | ------------ 57 | 58 | This feature is not without risks if used casually. Instruct your users 59 | carefully! Also make sure the security password can never be the same as the 60 | regular password because in that case it just won't work. 61 | 62 | Messages that have been queued for deletion *can*, if required, be restored to 63 | visibility by a system adminitrator by setting the status field. If the 64 | security action was set to '1' however, only a restore from backup of the 65 | database will bring back the deleted mail. 66 | 67 | 68 | LDAP support is currently not available. Please contact support@nfg.nl if you 69 | required this feature and need LDAP authentication. 70 | 71 | #EOF 72 | -------------------------------------------------------------------------------- /src/imapcommands.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl 3 | Copyright (c) 2004-2012 NFG Net Facilities Group BV support@nfg.nl 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | /* 22 | * imapcommands.h 23 | * 24 | * IMAP server command prototypes 25 | */ 26 | 27 | #ifndef DM_IMAP_COMMANDS_H 28 | #define DM_IMAP_COMMANDS_H 29 | 30 | #include "dbmail.h" 31 | 32 | /* any-state commands */ 33 | int _ic_starttls(ImapSession *self); 34 | int _ic_capability(ImapSession *self); 35 | int _ic_noop(ImapSession *self); 36 | int _ic_logout(ImapSession *self); 37 | int _ic_id(ImapSession *self); 38 | 39 | /* non-auth state commands */ 40 | int _ic_login(ImapSession *self); 41 | int _ic_authenticate(ImapSession *self); 42 | 43 | /* auth state commands */ 44 | int _ic_select(ImapSession *self); 45 | int _ic_examine(ImapSession *self); 46 | int _ic_enable(ImapSession *); 47 | int _ic_create(ImapSession *self); 48 | int _ic_delete(ImapSession *self); 49 | int _ic_rename(ImapSession *self); 50 | int _ic_subscribe(ImapSession *self); 51 | int _ic_unsubscribe(ImapSession *self); 52 | int _ic_list(ImapSession *self); 53 | int _ic_lsub(ImapSession *self); 54 | int _ic_status(ImapSession *self); 55 | int _ic_append(ImapSession *self); 56 | 57 | /* selected-state commands */ 58 | int _ic_sort(ImapSession *self); 59 | int _ic_check(ImapSession *self); 60 | int _ic_close(ImapSession *self); 61 | int _ic_idle(ImapSession *self); 62 | int _ic_unselect(ImapSession *self); 63 | int _ic_expunge(ImapSession *self); 64 | int _ic_search(ImapSession *self); 65 | int _ic_fetch(ImapSession *self); 66 | int _ic_store(ImapSession *self); 67 | int _ic_copy(ImapSession *self); 68 | int _ic_uid(ImapSession *self); 69 | int _ic_thread(ImapSession *self); 70 | 71 | /* quota commands */ 72 | int _ic_getquotaroot(ImapSession *self); 73 | int _ic_getquota(ImapSession *self); 74 | 75 | /* acl commands */ 76 | 77 | /** 78 | * \brief SETACL command 79 | */ 80 | int _ic_setacl(ImapSession *self); 81 | /** 82 | * DELETEACL command 83 | */ 84 | int _ic_deleteacl(ImapSession *self); 85 | /** 86 | * GETACL command 87 | */ 88 | int _ic_getacl(ImapSession *self); 89 | /** 90 | * LISTRIGHTS command 91 | */ 92 | int _ic_listrights(ImapSession *self); 93 | /** 94 | * MYRIGHTS command 95 | */ 96 | int _ic_myrights(ImapSession *self); 97 | /** 98 | * NAMESPACE command 99 | */ 100 | int _ic_namespace(ImapSession *self); 101 | #endif 102 | -------------------------------------------------------------------------------- /src/dm_cram.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (c) 2008-2012 NFG Net Facilities Group BV support@nfg.nl 4 | 5 | This program is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU General Public License 7 | as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include "dbmail.h" 22 | #include "dm_cram.h" 23 | 24 | #define THIS_MODULE "CRAM" 25 | 26 | /* 27 | */ 28 | 29 | #define T Cram_T 30 | 31 | struct T { 32 | char *challenge; 33 | char *username; 34 | char *response; 35 | }; 36 | 37 | T Cram_new(void) 38 | { 39 | T C; 40 | C = g_malloc0(sizeof(*C)); 41 | return C; 42 | } 43 | 44 | static gchar * init_challenge(void) 45 | { 46 | char name[255]; 47 | memset(name,0, sizeof(name)); 48 | if (getdomainname(name,sizeof(name)-1)) { 49 | if (gethostname(name, sizeof(name)-1)) 50 | strcpy(name,"(none)"); 51 | } 52 | return g_mime_utils_generate_message_id(name); 53 | } 54 | 55 | void Cram_setChallenge(T C, const char *challenge) 56 | { 57 | if (! challenge) 58 | C->challenge = init_challenge(); 59 | else 60 | C->challenge = g_strdup(challenge); 61 | } 62 | 63 | const gchar * Cram_getChallenge(T C) 64 | { 65 | if (! C->challenge) 66 | Cram_setChallenge(C, NULL); 67 | return (const gchar *)C->challenge; 68 | } 69 | 70 | const gchar * Cram_getUsername(T C) 71 | { 72 | assert(C->username); 73 | return C->username; 74 | } 75 | 76 | gboolean Cram_decode(T C, const char * response) 77 | { 78 | uint64_t len = 0, space = 0; 79 | gchar *s = dm_base64_decode(response, &len); 80 | space = stridx((const char *)s,' '); 81 | if (space == len) 82 | return FALSE; 83 | C->username = g_strndup(s, space); 84 | space++; 85 | C->response = g_strndup(s + space, len - space); 86 | g_free(s); 87 | return TRUE; 88 | } 89 | 90 | gboolean Cram_verify(T C, const char *credentials) 91 | { 92 | gboolean r = FALSE; 93 | unsigned char d[FIELDSIZE]; 94 | char hash[FIELDSIZE]; 95 | 96 | memset(d, 0, sizeof(d)); 97 | memset(hash, 0, sizeof(hash)); 98 | 99 | MHASH ctx = mhash_hmac_init(MHASH_MD5, (void *)credentials, strlen(credentials), mhash_get_hash_pblock(MHASH_MD5)); 100 | mhash(ctx, C->challenge, strlen(C->challenge)); 101 | mhash_hmac_deinit(ctx, (gpointer)d); 102 | dm_digest(d, MHASH_MD5, hash); 103 | 104 | if (strncmp(C->response, hash, strlen(C->response))==0) 105 | r = TRUE; 106 | 107 | return r; 108 | } 109 | 110 | void Cram_free(T *C) 111 | { 112 | T c = *C; 113 | if (c->challenge) g_free(c->challenge); 114 | if (c->username) g_free(c->username); 115 | if (c->response) g_free(c->response); 116 | g_free(c); 117 | c = NULL; 118 | } 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /test/check_dbmail_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2005-2012 NFG Net Facilities Group BV support@nfg.nl 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later 8 | * version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | * 20 | * 21 | * 22 | * 23 | * 24 | * 25 | * Basic unit-test framework for dbmail (www.dbmail.org) 26 | * 27 | * See http://check.sf.net for details and docs. 28 | * 29 | * 30 | * Run 'make check' to see some action. 31 | * 32 | */ 33 | 34 | #include 35 | #include "check_dbmail.h" 36 | 37 | extern char configFile[PATH_MAX]; 38 | extern DBParam_T db_params; 39 | 40 | 41 | extern uint64_t msgbuf_idx; 42 | extern uint64_t msgbuf_buflen; 43 | 44 | extern char *multipart_message; 45 | extern char *multipart_message_part; 46 | extern char *raw_lmtp_data; 47 | 48 | /* 49 | * 50 | * the test fixtures 51 | * 52 | */ 53 | 54 | 55 | void setup(void) 56 | { 57 | config_get_file(); 58 | config_read(configFile); 59 | configure_debug(NULL,255,0); 60 | GetDBParams(); 61 | db_connect(); 62 | } 63 | 64 | void teardown(void) 65 | { 66 | db_disconnect(); 67 | config_free(); 68 | } 69 | 70 | START_TEST(test_read_config) 71 | { 72 | fail_unless(db_params.host != NULL, "db_host is NULL"); 73 | } 74 | END_TEST 75 | 76 | START_TEST(test_db_connect) 77 | { 78 | int res; 79 | db_disconnect(); 80 | res = db_connect(); 81 | fail_unless(res==0, "Unable to connect to db"); 82 | } 83 | END_TEST 84 | 85 | START_TEST(test_glog) 86 | { 87 | // this should not print anything on stdout/stderr 88 | g_log("test",G_LOG_LEVEL_CRITICAL, "this should not be printed"); 89 | } 90 | END_TEST 91 | 92 | Suite *dbmail_common_suite(void) 93 | { 94 | Suite *s = suite_create("Dbmail Common"); 95 | TCase *tc_config = tcase_create("Config"); 96 | //TCase *tc_main = tcase_create("Main"); 97 | 98 | suite_add_tcase(s, tc_config); 99 | //suite_add_tcase(s, tc_main); 100 | 101 | tcase_add_checked_fixture(tc_config, setup, teardown); 102 | tcase_add_test(tc_config, test_read_config); 103 | tcase_add_test(tc_config, test_db_connect); 104 | tcase_add_test(tc_config, test_glog); 105 | 106 | //tcase_add_checked_fixture(tc_main, setup, teardown); 107 | return s; 108 | } 109 | 110 | int main(void) 111 | { 112 | int nf; 113 | Suite *s = dbmail_common_suite(); 114 | SRunner *sr = srunner_create(s); 115 | srunner_run_all(sr, CK_NORMAL); 116 | nf = srunner_ntests_failed(sr); 117 | srunner_free(sr); 118 | return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 119 | } 120 | 121 | 122 | -------------------------------------------------------------------------------- /test-scripts/python/compare.py: -------------------------------------------------------------------------------- 1 | 2 | import sys 3 | import hashlib 4 | import imaplib 5 | import poplib 6 | from multiprocessing import Pool 7 | 8 | 9 | HOST = 'localhost' 10 | USER = 'testuser1' 11 | PASS = 'test' 12 | CLIENTS = 30 13 | 14 | IMAP_PORT = 10143 15 | POP3_PORT = 10110 16 | 17 | tlocks = {} 18 | tdict = {} 19 | 20 | IMAP_BASELINE = None 21 | POP3_BASELINE = None 22 | 23 | 24 | def imap_messages(): 25 | IMAP = imaplib.IMAP4(HOST, IMAP_PORT) 26 | IMAP.login(USER, PASS) 27 | IMAP.select('INBOX') 28 | result = IMAP.fetch('1:*', '(RFC822)') 29 | IMAP.logout() 30 | result = [x for x in result[1] if type(x) == tuple] 31 | result = [x[1] for x in result] 32 | result = [x.replace('\r', '') for x in result] 33 | return [(hashlib.sha1(x).hexdigest(), x) for x in result] 34 | 35 | 36 | def pop_messages(): 37 | POP = poplib.POP3(HOST, POP3_PORT) 38 | POP.user(USER) 39 | POP.pass_(PASS) 40 | l = POP.list() 41 | count = int(l[0].split()[1]) 42 | result = [] 43 | for i in range(1, count + 1): 44 | message = POP.retr(i) 45 | message = '\n'.join(message[1]) 46 | message.replace('\r', '') 47 | result.append((hashlib.sha1(message).hexdigest(), message)) 48 | POP.quit() 49 | return result 50 | 51 | 52 | def do_compare(left, right): 53 | assert(len(left) == len(right)) 54 | for i in range(0, len(left)): 55 | if left[0] != right[0]: 56 | return "checksum error at [%d] %s != %s\n" % ( 57 | i, left[0], right[0]) 58 | return 59 | 60 | 61 | def imaploader(*args): 62 | for i in range(0, 10): 63 | try: 64 | results = imap_messages() 65 | except: 66 | continue 67 | error = do_compare(IMAP_BASELINE, results) 68 | if error: 69 | return error 70 | 71 | sys.stdout.write('.') 72 | sys.stdout.flush() 73 | return 74 | 75 | 76 | def pop3loader(*args): 77 | for i in range(0, 10): 78 | results = pop_messages() 79 | do_compare(POP3_BASELINE, results) 80 | sys.stdout.write(',') 81 | sys.stdout.flush() 82 | return 83 | 84 | 85 | if __name__ == '__main__': 86 | print "fetch all messages over IMAP..." 87 | IMAP_BASELINE = imap_messages() 88 | print "fetch all messages over POP3..." 89 | POP3_BASELINE = pop_messages() 90 | print "comparing results for %s messages..." % len(IMAP_BASELINE) 91 | do_compare(IMAP_BASELINE, POP3_BASELINE) 92 | 93 | pool = Pool(processes=CLIENTS * 2) 94 | pop3_result = pool.map_async(pop3loader, range(0, CLIENTS)) 95 | imap_result = pool.map_async(imaploader, range(0, CLIENTS), 1) 96 | pop3_errors = pop3_result.get() 97 | imap_errors = imap_result.get() 98 | pool.close() 99 | pool.join() 100 | 101 | sys.stdout.write('\n') 102 | pop3_errors = [x for x in pop3_errors if x] 103 | imap_errors = [x for x in imap_errors if x] 104 | if pop3_errors: 105 | print "POP3 errors", pop3_errors 106 | if imap_errors: 107 | print "IMAP errors", imap_errors 108 | if imap_errors or pop3_errors: 109 | sys.exit(1) 110 | print "done." 111 | sys.exit(0) 112 | --------------------------------------------------------------------------------