virtual mail dengan postfix, dovecot, mysql, dan squirrelmail

database struktur

--
-- Database: `mailserver`
--

-- --------------------------------------------------------

--
-- Table structure for table `virtual_aliases`
--

CREATE TABLE IF NOT EXISTS `virtual_aliases` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`domain_id` int(11) NOT NULL,
`source` varchar(100) NOT NULL,
`destination` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
KEY `domain_id` (`domain_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `virtual_aliases`
--

INSERT INTO `virtual_aliases` (`id`, `domain_id`, `source`, `destination`) VALUES
(1, 1, 'jack@example.box', 'john@example.box');

-- --------------------------------------------------------

--
-- Table structure for table `virtual_domains`
--

CREATE TABLE IF NOT EXISTS `virtual_domains` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `virtual_domains`
--

INSERT INTO `virtual_domains` (`id`, `name`) VALUES
(1, 'example.box'),
(2, 'example.bkd');

-- --------------------------------------------------------

--
-- Table structure for table `virtual_users`
--

CREATE TABLE IF NOT EXISTS `virtual_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`domain_id` int(11) NOT NULL,
`password` varchar(32) NOT NULL,
`email` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`),
KEY `domain_id` (`domain_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

--
-- Dumping data for table `virtual_users`
--

INSERT INTO `virtual_users` (`id`, `domain_id`, `password`, `email`) VALUES
(1, 1, '527bd5b5d689e2c32ae974c6229ff785', 'john@example.box'),
(2, 2, '527bd5b5d689e2c32ae974c6229ff785', 'john@example.bkd'),
(3, 1, '44529fdc8afb86d58c6c02cd00c02e43', 'paijo@example.box');

--
-- Constraints for dumped tables
--

--
-- Constraints for table `virtual_aliases`
--
ALTER TABLE `virtual_aliases`
ADD CONSTRAINT `virtual_aliases_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `virtual_domains` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `virtual_users`
--
ALTER TABLE `virtual_users`
ADD CONSTRAINT `virtual_users_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `virtual_domains` (`id`) ON DELETE CASCADE;

dovecot.conf

sudo dovecot -n
# 2.1.7: /etc/dovecot/dovecot.conf
# OS: Linux 3.2.0-3-amd64 x86_64 Debian wheezy/sid
auth_debug = yes
auth_mechanisms = plain login
auth_verbose = yes
disable_plaintext_auth = no
mail_gid = vmail
mail_location = maildir:~/Maildir
mail_uid = vmail
namespace {
inbox = yes
location =
prefix =
separator = .
type = private
}
passdb {
args = /etc/dovecot/dovecot-sql.conf.ext
driver = sql
}
passdb {
driver = pam
}
postmaster_address = postmaster@example.box
protocols = imap pop3
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0666
user = postfix
}
unix_listener auth-userdb {
group = vmail
mode = 0666
user = vmail
}
user = $default_internal_user
}
ssl_cert = </etc/ssl/certs/dovecot.pem
ssl_key = </etc/ssl/private/dovecot.pem
userdb {
args = uid=5000 gid=5000 home=/var/vmail/%d/%n/Maildir allow_all_users=yes
driver = static
}
userdb {
driver = passwd
}
protocol lda {
mail_plugins =
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: