Dando sequencia ao nosso tutorial de configuracao de uma solucao completa de Mail Server, segue abaixo as configuracoes do Dovecot e do RoundCube!Configuracao do Dovecot (pop/imap) Para iniciar a configuracao, iremos editar o arquivo dovecot.conf, podemos apagar as linhas atuais do arquivo e substituir conforme abaixo: # > /etc/dovecot.conf# vim /etc/dovecot.confAtente para as configuracoes de acordo com seu dominio: protocols = imap pop3 imaps pop3s listen = * login_process_size = 64 default_mail_env = maildir:/home/virtual_mail/%u/ namespace private { separator = . prefix = INBOX. inbox = yes} namespace private {separator = .prefix =inbox = yeshidden = yes} mail_access_groups = postfixmail_privileged_group = postfix verbose_proctitle = yes first_valid_uid = 89 first_valid_gid = 89 #umask = 0077 mbox_read_locks = fcntl mbox_write_locks = fcntl ## Ssl section ssl_disable = no ssl_cert_file = /etc/pki/dovecot/certs/dovecot.pem ssl_key_file = /etc/pki/dovecot/private/dovecot.pem # If key file is password protected, give the password here. Alternatively# give it when starting dovecot with -p parameter. ssl_key_password = protocol imap { imap_client_workarounds = delay-newmail outlook-idle netscape-eoh tb-extra-mailbox-sep mail_executable = /usr/libexec/dovecot/popbsmtp.sh /usr/libexec/dovecot/imap } #People who use outlook are fux0red anyway...protocol pop3 { pop3_uidl_format = %08Xu%08Xv pop3_client_workarounds = outlook-no-nuls oe-ns-eoh mail_executable = /usr/libexec/dovecot/popbsmtp.sh /usr/libexec/dovecot/pop3} protocol lda { postmaster_address = suporte@empresaX.com.br sendmail_path = /usr/sbin/sendmail } auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@auth_debug = yes auth_verbose = yes auth default { mechanisms = plain login passdb sql { args = /etc/dovecot-mysql.conf } userdb sql { args = /etc/dovecot-mysql.conf } socket listen { client { path = /var/spool/postfix/private/auth mode = 432 user = postfix group = postfix } master { path = /var/run/dovecot/auth-master mode = 384 user = postfix }}} Criando o arquivo de configuracao para o MySql: # vim /etc/dovecot-mysql.conf E adicione as seguintes linhas: # Database driver: mysql, pgsql driver = mysql # Currently supported schemes include PLAIN, PLAIN-MD5, DIGEST-MD5, and CRYPT. default_pass_scheme = CRYPT # Database options connect = host=localhost dbname=mails user=postfix password=mail password_query = SELECT password FROM mailbox WHERE username = '%u' AND active = '1' user_query = SELECT maildir, 89 AS uid, 89 AS gid FROM mailbox WHERE username = '%u' AND active = '1' Adicionando o script do PopBeforeSMTP: # vim /usr/libexec/dovecot/popbsmtp.sh #!/bin/sh pass='mail' ( if [ -n "$IP" ] then echo "REPLACE INTO mails.popbsmtp (address,last_seen) VALUES ('$IP', NOW( ))" \ | mysql -u postfix -p$pass -h localhost > /dev/null 2>&1 fi ) exec "$@" Adicionando a permissao: # chmod 755 /usr/libexec/dovecot/popbsmtp.sh Agora ja podemos reiniciar o Dovecot: # /etc/init.d/dovecot restart Adicionando o servico para ser inicializado no momento do boot: # chkconfig --levels 345 dovecot on Adicionando na cron a execucao do PopBeforeSMTP a cada hora: # vim /etc/cron.hourly/popbsmtp_purge #!/bin/sh user="postfix" pass="mail" host="localhost" database="mails" ## Delete IP before not get activity for 120 minutes echo "DELETE FROM $database.popbsmtp WHERE last_seen < DATE_SUB(NOW(),INTERVAL 120 MINUTE)" | mysql -u $user -p$pass -h $host > /dev/null 2>&1 Adicionando permissao de execucao:# chmod 755 /etc/cron.hourly/popbsmtp_purge Configuracao do RoundCube (webmail) Para instalacao do RoundCube e necessario que as seguintes dependencias estejam previamente resolvidas: - Apache - PHP 5.2.1 ou mais atual - MySQL - Servidor Imap e SMTP Apos a instalacao das dependencias iremos fazer o download do RoundCube atraves do site oficial: #