OpenSMTPDAdmin
Go to file
mischa 8c6594692a better sentence 2023-10-16 11:01:08 +00:00
VIRTUAL_VACATION remove some LF/CR 2022-08-22 18:51:26 +00:00
admin no need to define template file anymore 2022-09-20 17:54:32 +00:00
images Initial commit 2022-08-18 14:01:52 +02:00
languages configurable LOG_SIZE to display 2022-09-06 14:55:29 +00:00
templates change link to https://code.high5.nl/High5/opensmtpdadmin 2023-10-14 19:12:32 +00:00
.gitignore rip and replace.. start 2022-09-02 21:06:08 +00:00
CHANGELOG.TXT no reason to have 3 digit version numbers 2023-10-15 08:08:26 +00:00
LICENSE.TXT Initial commit 2022-08-18 14:01:52 +02:00
README.md better sentence 2023-10-16 11:01:08 +00:00
add-alias.php remove domain_exists where it makes less sense, fix search 2022-09-06 12:29:52 +00:00
add-mailbox.php remove domain_exists where it makes less sense, fix search 2022-09-06 12:29:52 +00:00
admin.php change check_role() to query 2022-09-06 11:56:05 +00:00
backup.php change check_role() to query 2022-09-06 11:56:05 +00:00
conf.php-sample change c for conf.php-sample 2023-10-15 08:03:22 +00:00
delete.php change check_role() to query 2022-09-06 11:56:05 +00:00
domain.php change check_role() to query 2022-09-06 11:56:05 +00:00
edit-alias.php remove domain_exists where it makes less sense, fix search 2022-09-06 12:29:52 +00:00
edit-mailbox.php remove domain_exists where it makes less sense, fix search 2022-09-06 12:29:52 +00:00
favicon.ico adding favicon.ico 2022-09-06 14:06:06 +00:00
functions.inc.php no reason to have 3 digit version numbers 2023-10-15 08:08:26 +00:00
index.php merge admin + superadmin 2022-09-05 18:29:41 +00:00
list-admin.php change check_role() to query 2022-09-06 11:56:05 +00:00
list-domain.php change check_role() to query 2022-09-06 11:56:05 +00:00
list-virtual.php change check_role() to query 2022-09-06 11:56:05 +00:00
login.php change check_role() to query 2022-09-06 11:56:05 +00:00
logout.php merge admin + superadmin 2022-09-05 18:29:41 +00:00
password.php strip domain from SESSID_USERNAME 2022-09-06 14:44:44 +00:00
search.php change check_role() to query 2022-09-06 11:56:05 +00:00
sendmail.php change check_role() to query 2022-09-06 11:56:05 +00:00
setup.php use ADMIN_ROLE in stead of ADMIN_RIGHTS, like the rest of the code 2023-10-14 14:47:02 +00:00
stylesheet.css smaller font-size 2022-09-06 14:01:05 +00:00
vacation.php change check_role() to query 2022-09-06 11:56:05 +00:00
viewlog.php configurable LOG_SIZE to display 2022-09-06 14:55:29 +00:00

README.md

OpenSMTPD Admin

OpenSMTPD Admin started as a fork of Postfix Admin 2.1.0 (released in 2007), and grew quickly in a complete rewrite for OpenSMTPD.

Installation of packages

To get going on OpenBSD you will need to install the following packages:

mariadb-server
php
php-pdo_mysql

For OpenSMTPD you need the packages:

opensmtpd-extras
opensmtpd-extras-mysql

Once the packages are installed follow the steps outlined in /usr/local/share/doc/pkg-readmes

You need to create the database with:

CREATE DATABASE IF NOT EXISTS `opensmtpd` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `opensmtpd`;

CREATE TABLE `admin` (
  `username` varchar(255) NOT NULL DEFAULT '',
  `password` varchar(255) NOT NULL DEFAULT '',
  `role` varchar(32) DEFAULT NULL,
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`username`),
  KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Admins';

CREATE TABLE `alias` (
  `address` varchar(255) NOT NULL DEFAULT '',
  `goto` text NOT NULL,
  `domain` varchar(255) NOT NULL DEFAULT '',
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`address`),
  KEY `address` (`address`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Aliases';

CREATE TABLE `domain` (
  `domain` varchar(255) NOT NULL DEFAULT '',
  `description` varchar(255) NOT NULL DEFAULT '',
  `aliases` int(10) NOT NULL DEFAULT 0,
  `mailboxes` int(10) NOT NULL DEFAULT 0,
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`domain`),
  KEY `domain` (`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Domains';

CREATE TABLE `domain_admins` (
  `username` varchar(255) NOT NULL DEFAULT '',
  `domain` varchar(255) NOT NULL DEFAULT '',
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Domain Admins';

CREATE TABLE `log` (
  `timestamp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `username` varchar(255) NOT NULL DEFAULT '',
  `domain` varchar(255) NOT NULL DEFAULT '',
  `action` varchar(255) NOT NULL DEFAULT '',
  `data` varchar(255) NOT NULL DEFAULT '',
  KEY `timestamp` (`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Log';

CREATE TABLE `mailbox` (
  `username` varchar(255) NOT NULL DEFAULT '',
  `password` varchar(255) NOT NULL DEFAULT '',
  `name` varchar(255) NOT NULL DEFAULT '',
  `maildir` varchar(255) NOT NULL DEFAULT '',
  `domain` varchar(255) NOT NULL DEFAULT '',
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`username`),
  KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Mailboxes';

CREATE TABLE `vacation` (
  `email` varchar(255) NOT NULL DEFAULT '',
  `subject` varchar(255) NOT NULL DEFAULT '',
  `body` text NOT NULL,
  `cache` text NOT NULL,
  `domain` varchar(255) NOT NULL DEFAULT '',
  `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`email`),
  KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='OpenSMTPD Admin - Virtual Vacation';

You can create the database user with something like:

CREATE USER IF NOT EXISTS 'opensmtpd'@'localhost' IDENTIFIED BY 'RandomString';
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER ON opensmtpd.* TO 'opensmtpd'@'localhost';

As an example configuration for httpd you can use:

server "opensmtpadmin" {
	listen on * tls port 443
	tls {
		certificate "/etc/ssl/opensmtpdadmin.fullchain.pem"
		key "/etc/ssl/private/opensmtpadmin.key"
	}
	tcp { nodelay, sack }
	log style forwarded
	location "/admin/*" {
		authenticate with "/opensmtpdadmin/admin/.htpasswd"
		root "/opensmtpdadmin"
		fastcgi socket "/run/php-fpm.sock"
	}
	location "*.php*" {
		root "/opensmtpdadmin"
		directory index index.php
		fastcgi socket "/run/php-fpm.sock"
	}
	location "/*" {
		root "/opensmtpdadmin"
		directory index index.php
	}
}

As soon as that is done you can go to https://YOURHOST/
You will be greeted by setup.php to check if everything is present to run OpenSMTPDAdmin.

Copy or move the conf.php-sample to conf.php and make the needed changes for your setup.
You can remove setup.php if you want.

After that you can go to https://YOURHOST/admin/admin.php where you create the SUPER ADMIN.
NOTE: Once this is done, either remove or protect /admin/admin.php.

You are now ready to use OpenSMTPDAdmin.

To use the accounts OpenSMTPDAdmin create in OpenSMTPD you can use the below config:

# /etc/mail/smtpd.conf
table credentials mysql:/etc/mail/sql.conf
table domains mysql:/etc/mail/sql.conf
table userinfo mysql:/etc/mail/sql.conf
table virtuals mysql:/etc/mail/sql.conf

Connecting the database to smtpd:

# /etc/mail/sql.conf
host            localhost
username        opensmtpd
password        RandomString 
database        opensmtpd

query_alias             SELECT goto FROM alias WHERE address=?;
query_credentials       SELECT username, password FROM mailbox WHERE username=?;
query_domain            SELECT domain FROM domain WHERE domain=?;
query_userinfo          SELECT 501, 501, maildir FROM mailbox WHERE username=?;