Differences

This shows you the differences between two versions of the page.

Link to this comparison view

instalacao_e_configuracao_do_qmail_quota_webmail_vqadmin_qmailadmin_squeeze_pt_br [2017/09/05 12:18] (current)
Line 1: Line 1:
 +====== Instalação e configuração do Qmail + Quota + Webmail + Vqadmin + Qmailadmin + Debian Squeeze ​ ======
  
 +
 +  - Nome da máquina: mail.douglasqsantos.com.br
 +  - Domínio: douglasqsantos.com.br
 +  - É necessário a configuração de um servidor DNS.
 +
 +Prepare o seu sistema com o seguinte script [[https://​github.com/​douglasqsantos/​easy-debian|Easy-Debian]] para que não falte nenhum pacote ou configuração.
 +
 +
 +Vamos fazer um update dos repositórios e um upgrade do sistema ​
 +<sxh bash>
 +
 +aptitude update && aptitude dist-upgrade -y
 +</​sxh>​
 +
 +Agora vamos instalar alguns pacotes necessários ​
 +
 +Vamos instalar o Daemontools e ucspi-tcp ​
 +<sxh bash>
 +
 +aptitude install ucspi-tcp daemontools daemontools-run -y
 +</​sxh>​
 +
 +Vamos instalar o courier ​
 +<sxh bash>
 +
 +aptitude install courier-base courier-authdaemon courier-authlib courier-authlib-mysql courier-imap \
 + ​courier-imap-ssl courier-pop-ssl courier-pop courierpassd courier-maildrop gamin -y
 +</​sxh>​
 +
 +Agora vamos instalar algumas ferramentas necessarias ​
 +<sxh bash>
 +
 +aptitude install cpp g++ gcc make automake wget telnet libtool patch patchutils logrotate dh-make-perl libltdl7 \
 +equivs expect openssl libssl-dev libgmp3-dev libgdbm-dev libpcre++-dev libpcre-ocaml libpcre-ocaml-dev -y
 +</​sxh>​
 +
 +Agora vamos instalar o MySQL 
 +<sxh bash>
 +
 +aptitude install mysql-common mysql-server-5.1 mysql-client-5.1 mysql-server-core-5.1 libmysqlclient16 \
 +libmysqlclient-dev -y
 +</​sxh>​
 +
 +Agora vamos instalar o Apache e PHP 
 +<sxh bash>
 +
 +aptitude install apache2 php5 php5-common libapache2-mod-php5 php5-mysql php5-imap php5-mcrypt php5-json \
 + ​php5-xmlrpc php5-dev php-pear php5-intl php5-gd php5-mcrypt -y
 +</​sxh> ​
 +
 +Agora vamos instalar o Anti-spam e Anti-Vírus ​
 +<sxh bash>
 +
 +aptitude install spamassassin spamc pyzor razor clamav clamav-daemon clamav-docs -y
 +</​sxh>​
 +
 +Agora vamos instalar os desempacotadores necessários
 +<sxh bash>
 +
 +aptitude install arj unrar lha unzip bzip2 tar tnef -y
 +</​sxh>​
 +
 +Agora vamos instalar os módulos perl necessários ​
 +<sxh bash>
 +
 +aptitude install perl-suid spf-tools-perl libmailtools-perl libnet-cidr-lite-perl libnet-daemon-perl \
 +libtest-distribution-perl libmail-spf-perl libperl-dev -y
 +</​sxh>​
 +
 +Mais alguns módulos perl
 +
 +<sxh bash>
 +aptitude install libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl perl-doc \
 +libdate-manip-perl libio-string-perl libio-socket-ssl-perl libnet-ident-perl libsys-syslog-perl \
 +libencode-detect-perl -y
 +</​sxh>​
 +
 +Mais alguns módulos perl
 +<sxh bash>
 +aptitude install libnet-dns-perl libplrpc-perl libtimedate-perl libcompress-zlib-perl libdigest-hmac-perl \
 +libdigest-sha1-perl libparse-syslog-perl libmail-dkim-perl libcrypt-openssl-bignum-perl -y
 +</​sxh>​
 +
 +Agora vamos instalar algumas ferramentas de manipulação do sistema  ​
 +<sxh bash>
 +
 +aptitude install dnsutils whois findutils pciutils less net-tools tcpdump iptraf dstat iotop mc locate -y
 +</​sxh>​
 +
 +Agora vamos obter os pacotes que vão ser necessários para a nossa implementação ​
 +<sxh bash>
 +
 +mkdir /downloads
 +cd /downloads
 +wget -c http://​wiki.douglasqsantos.com.br/​Downloads/​mail/​debian-qmr.tar.gz
 +tar zxvf debian-qmr.tar.gz
 +</​sxh>​
 +
 +Agora vamos acertar agora os usuários para o sistema ​
 +
 +Vamos acertar os grupos ​
 +<sxh bash>
 +
 +groupadd -g 161 nofiles
 +groupadd -g 162 qmail
 +groupadd -g 163 qscand
 +groupadd -g 89 vchkpw
 +</​sxh>​
 +
 +Agora vamos acertar os usuários ​
 +<sxh bash>
 +
 +useradd -u 161 -g nofiles -d /​var/​qmail/​alias -s /​usr/​sbin/​nologin -p’*’ -c 'QMail alias user' alias
 +useradd -u 162 -g nofiles -d /var/qmail -s /​usr/​sbin/​nologin -p’*’ -c 'QMail daemon user' qmaild
 +useradd -u 163 -g nofiles -d /var/qmail -s /​usr/​sbin/​nologin -p’*’ -c 'QMail log user' qmaill
 +useradd -u 164 -g nofiles -d /var/qmail -s /​usr/​sbin/​nologin -p’*’ -c 'QMail password user' qmailp
 +useradd -u 165 -g qmail -d /var/qmail -s /​usr/​sbin/​nologin -p’*’ -c 'QMail queue user' qmailq
 +useradd -u 166 -g qmail -d /var/qmail -s /​usr/​sbin/​nologin -p’*’ -c 'QMail remote user' qmailr
 +useradd -u 167 -g qmail -d /var/qmail -s /​usr/​sbin/​nologin -p’*’ -c 'QMail send user' qmails
 +useradd -u 89 -g vchkpw -d /​home/​vpopmail -s /​usr/​sbin/​nologin -p’*’ -c '​Vpopmail (virtual domains) user' vpopmail
 +useradd -u 168 -g qscand -d /bin/false -s /​usr/​sbin/​nologin -p’*’ -c '​Antivirus user' qscand
 +</​sxh>​
 +
 +Agora vamos acertar os diretórios necessários ​
 +<sxh bash>
 +
 +mkdir /var/qmail
 +mkdir /​usr/​src/​qmail
 +mkdir -p /​var/​log/​qmail/​qmail-send
 +mkdir -p /​var/​log/​qmail/​qmail-smtpd
 +mkdir -p /​var/​log/​qmail/​qmail-smtpdssl
 +chown -R qmaill:root /​var/​log/​qmail
 +chmod -R 750 /​var/​log/​qmail ​
 +</​sxh>​
 +
 +Agora vamos instalação do Qmail 
 +<sxh bash>
 +
 +cd /​usr/​src/​qmail
 +tar -zxvf /​downloads/​qmail-1.03.tar.gz
 +</​sxh>​
 +
 +Vamos precisar aplicar um patch nele 
 +<sxh bash>
 +
 +cd /​usr/​src/​qmail/​qmail-1.03
 +patch < /​downloads/​patches/​qmail-1.03-jms1-7.10.patch
 +</​sxh>​
 +
 +Vamos compilar e instalar ele
 +<sxh bash>
 +
 +make man
 +make setup check
 +</​sxh>​
 +
 +Vamos acertar a configuração dos manuais do qmail 
 +<sxh bash>
 +
 +echo '​MANDATORY_MANPATH /​var/​qmail/​man'​ >> /​etc/​manpath.config
 +ln -s /​var/​qmail/​control /etc/qmail
 +</​sxh>​
 +
 +Agora vamos acertar o TLS para o Qmail 
 +<sxh bash>
 +
 +sed -i '​s/​-days 366/-days 3650/' Makefile
 +</​sxh>​
 +
 +Agora vamos gerar o certificado
 +<sxh bash>
 +
 +make cert
 +
 +Country Name (2 letter code) [AU]:BR
 +State or Province Name (full name) [Some-State]:​Parana
 +Locality Name (eg, city) []:Curitiba
 +Organization Name (eg, company) [Internet Widgits Pty Ltd]:​Douglas
 +Organizational Unit Name (eg, section) []:TI
 +Common Name (eg, YOUR name) []:​mail.douglasqsantos.com.br
 +Email Address []:​postmaster@douglasqsantos.com.br
 +</​sxh>​
 +
 +Agora vamos acertar as permissões dos certificados
 +<sxh bash>
 +
 +cd /​var/​qmail/​control
 +chmod 640 servercert.pem
 +chown vpopmail:​vchkpw servercert.pem
 +rm clientcert.pem
 +cp servercert.pem clientcert.pem
 +chown root:qmail clientcert.pem
 +chmod 640 clientcert.pem
 +</​sxh>​
 +
 +Agora vamos a instalação do UCSPI-SSL pois não temos ele em repositório ​
 +
 +Vamos preparar o pacote ​
 +<sxh bash>
 +
 +mkdir /packages
 +chmod 1755 /packages
 +cd /tmp
 +tar -zxvf /​downloads/​ucspi-ssl-0.70.tar.gz
 +</​sxh>​
 +
 +Vamos acertar o pacote ​
 +<sxh bash>
 +
 +mv /​tmp/​host/​superscript.com/​net/​ucspi-ssl-0.70/​ /packages
 +cd /​packages/​ucspi-ssl-0.70/​
 +rm -rf /tmp/host/
 +</​sxh>​
 +
 +Agora vamos acertar a configuração do pacote e o chave de criptografia ​
 +<sxh bash>
 +
 +sed -i '​s/​local\/'​ src/​conf-tcpbin
 +sed -i '​s/​usr\/​local/​etc/'​ src/​conf-cadir
 +sed -i '​s/​usr\/​local\/​ssl\/​pem/​etc\/​ssl/'​ src/​conf-dhfile
 +openssl dhparam -check -text -5 1024 -out /​etc/​ssl/​dh1024.pem #Aqui estamos definindo o tamanho de bits da chave
 +</​sxh>​
 +
 +Agora vamos compilar o pacote ​
 +<sxh bash>
 +
 +package/​compile
 +package/rts #Aqui vamos obter algumas mensagens de erros que podem ser ignoradas
 +package/​install
 +</​sxh>​
 +
 +Agora vamos instalar o Ezmlm que é usado para gerenciar listas de distribuição de e-mails ​
 +
 +Agora vamos acessar o ezml  e desempacotar ele e criar um link para acertar o idioma
 +<sxh bash>
 +
 +cd /downloads/
 +tar zxvfp ezmlm-idx-7.1.1.tar.gz
 +cd /​downloads/​ezmlm-idx-7.1.1
 +ln -s /​downloads/​ezmlm-idx-7.1.1/​lang/​en_US/​ /​downloads/​ezmlm-idx-7.1.1/​lang/​default
 +</​sxh>​
 +
 +Agora vamos compilar e instalar ele
 +<sxh bash>
 +
 +make clean
 +make; make man
 +</​sxh>​
 +
 +Agora vamos testar a configuração ​
 +<sxh bash>
 +
 +./​ezmlm-test ​
 +getconfopt library: ​  OK
 +ezmlm-make: ​          OK
 +Using subdb plugin: ​  std
 +ezmlm-reject: ​        OK
 +ezmlm-[un|is]sub[n]: ​ OK
 +ezmlm-checksub: ​      OK
 +ezmlm-send: ​          OK
 +ezmlm-tstdig: ​        OK
 +ezmlm-weed: ​          OK
 +ezmlmrc contents: ​    OK
 +ezmlm-clean: ​         OK
 +ezmlm-store: ​         OK
 +ezmlm-return: ​        OK
 +ezmlm-warn (1/​2): ​    OK
 +ezmlm-manage (1/​2): ​  OK
 +ezmlm-request: ​       OK
 +ezmlm-split: ​         OK
 +ezmlm-gate: ​          OK
 +ezmlm-idx: ​           OK
 +ezmlm-get (index): ​   OK
 +ezmlm-get (get): ​     OK
 +ezmlm-get (thread): ​  OK
 +ezmlm-get (digest): ​  OK
 +ezmlm-manage (2/​2): ​  OK
 +ezmlm-moderate: ​      OK
 +ezmlm-warn (2/​2): ​    OK
 +ezmlm-archive: ​       OK
 +ezmlm-dispatch: ​      OK
 +dispatch editor: ​     OK
 +decode sender: ​       OK
 +Verifying message header and body contents...
 +flags: ​               OK
 +substitutions: ​       OK
 +messages: ​            OK
 +subscribe nop:        OK
 +unsubscribe nop:      OK
 +subscribe probe: ​     OK
 +unsubscribe probe: ​   OK
 +subscribe: ​           OK
 +unsubscribe: ​         OK
 +moderated subscribe: ​ OK
 +moderated unsub: ​     OK
 +subscribe by mod:     OK
 +unsubscribe by mod:   OK
 +copylines: ​           OK
 +ezmlm-send: ​          OK
 +ezmlm-send trailer: ​  OK
 +omitbottom (-manage): OK
 +omitbottom (-get): ​   OK
 +Cleaning up...
 +</​sxh>​
 +
 +Vamos acertar um arquivo para podermos continuar, o arquivo tem que ficar como abaixo ​
 +<sxh bash>
 +
 +vim /​downloads/​ezmlm-idx-7.1.1/​conf-ld
 +cc -g -B /​usr/​lib/​mysql/​
 +
 +This will be used to link .o files into an executable.
 +</​sxh>​
 +
 +Agora vamos criar a base de dados para o Ezmlm 
 +<sxh sql>
 +
 +mysql -u root -p 
 +CREATE DATABASE ezmlm;
 +GRANT ALL PRIVILEGES ON ezmlm.* TO ezmlmuser@localhost IDENTIFIED BY '​EZMLM_PASSWORD';​
 +FLUSH PRIVILEGES;
 +quit;
 +</​sxh>​
 +
 +Vamos testar a conexão da nossa nova conta do mysql 
 +<sxh sql>
 +
 +mysql -uezmlmuser -pEZMLM_PASSWORD
 +Welcome to the MySQL monitor. ​ Commands end with ; or \g.
 +Your MySQL connection id is 41
 +Server version: 5.1.49-3 (Debian)
 +
 +Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
 +This software comes with ABSOLUTELY NO WARRANTY. This is free software,
 +and you are welcome to modify and redistribute it under the GPL v2 license
 +
 +Type '​help;'​ or '​\h'​ for help. Type '​\c'​ to clear the current input statement.
 +
 +mysql> quit
 +Bye
 +</​sxh>​
 +
 +Agora vamos instalar o suporte ao mysql
 +<sxh bash>
 +
 +cd /​downloads/​ezmlm-idx-7.1.1
 +make mysql
 +</​sxh>​
 +
 +
 +Agora vamos testar o suporte ao MySQL 
 +<sxh bash>
 +
 +./​ezmlm-test -s mysql -u ezmlmuser -p EZMLM_PASSWORD -h localhost
 +[...]
 +ezmlm-make: ​          OK
 +Using subdb plugin: ​  mysql
 +[...]
 +ezmlm SQL:            OK
 +[...]
 +</​sxh>​
 +
 +Agora vamos instalar ele 
 +<sxh bash>
 +
 +make install ​
 +</​sxh>​
 +
 +Agora acessar e descompactar o AutoResponder ​
 +<sxh bash>
 +
 +cd /downloads/
 +tar zxvf autorespond-2.0.5.tar.gz
 +cd /​downloads/​autorespond-2.0.5
 +</​sxh>​
 +
 +Agora vamos mandar compilar e instalar ele
 +<sxh bash>
 +
 +make && make install
 +</​sxh>​
 +
 +Agora vamos instalar o Vpopmail que vai ser o responsável por gerenciar os domínio e usuários ​
 +
 +Vamos criar a base de dados para o Vpopmail vamos definir um usuário que vai ser vpopmailuser e a sua senha VPOPMAIL_PASSWORD
 +<sxh sql>
 +
 +mysql -u root -p 
 +CREATE DATABASE vpopmail;
 +GRANT select,​insert,​update,​delete,​create,​drop ON vpopmail.* TO vpopmailuser@localhost IDENTIFIED BY '​VPOPMAIL_PASSWORD';​
 +FLUSH PRIVILEGES;
 +quit;
 +</​sxh>​
 +
 +Agora vamos testar a conexão do nosso novo usuário ​
 +<sxh sql>
 +
 +mysql -uvpopmailuser -pVPOPMAIL_PASSWORD
 +Welcome to the MySQL monitor. ​ Commands end with ; or \g.
 +Your MySQL connection id is 279
 +Server version: 5.1.49-3 (Debian)
 +
 +Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
 +This software comes with ABSOLUTELY NO WARRANTY. This is free software,
 +and you are welcome to modify and redistribute it under the GPL v2 license
 +
 +Type '​help;'​ or '​\h'​ for help. Type '​\c'​ to clear the current input statement.
 +
 +mysql> quit
 +Bye
 +</​sxh>​
 +
 +Agora vamos preparar a instalação do Vpopmail ​
 +<sxh bash>
 +
 +mkdir -p /​home/​vpopmail/​etc
 +chown -R vpopmail:​vchkpw /​home/​vpopmail
 +chmod 770 /​home/​vpopmail
 +cd /​home/​vpopmail/​etc
 +</​sxh>​
 +
 +Agora vamos acertar a conexão do vpopmail com o MySQL aqui definimos o localhost que vai ser o servidor mysql o 0 define a porta padrão do MySQL o vpopmailuser o usuário de conexão com o banco de dados e o VPOPMAIL_PASSWORD a senha do usuário vpopmailuser
 +<sxh bash>
 +
 +echo "​localhost|0|vpopmailuser|VPOPMAIL_PASSWORD|vpopmail"​ > ~vpopmail/​etc/​vpopmail.mysql
 +chown vpopmail:​vchkpw ~vpopmail/​etc/​vpopmail.mysql
 +chmod 640 ~vpopmail/​etc/​vpopmail.mysql
 +</​sxh>​
 +
 +Agora vamos acessar e descompactar o vpopmail
 +<sxh bash>
 +
 +cd /downloads/
 +tar zxvf vpopmail-5.4.33.tar.gz
 +cd /​downloads/​vpopmail-5.4.33
 +</​sxh>​
 +
 +Agora vamos acertar os parâmetros de configuração dele
 +<sxh bash>
 +
 +./configure \
 +--enable-qmaildir=/​var/​qmail/​ \
 +--enable-qmail-newu=/​var/​qmail/​bin/​qmail-newu \
 +--enable-qmail-inject=/​var/​qmail/​bin/​qmail-inject \
 +--enable-qmail-newmrh=/​var/​qmail/​bin/​qmail-newmrh \
 +--enable-tcprules-prog=/​usr/​bin/​tcprules \
 +--enable-tcpserver-file=/​etc/​tcp.smtp \
 +--enable-clear-passwd \
 +--enable-many-domains \
 +--enable-valias \
 +--enable-qmail-ext \
 +--enable-logging=p \
 +--enable-auth-logging \
 +--enable-sql-logging \
 +--enable-auth-module=mysql \
 +--enable-incdir=/​usr/​include/​mysql \
 +--enable-libdir=/​usr/​lib/​ \
 +--disable-mysql-limits \
 +--disable-passwd
 +</​sxh>​
 +
 +Agora vamos mandar instalar ele
 +<sxh bash>
 +
 +make && make install-strip
 +</​sxh>​
 +
 +Vamos acertar mais um arquivo so para evitar problemas de segmentação ​
 +<sxh bash>
 +
 +cat > ~vpopmail/​etc/​vusagec.conf << EOF
 +Server:
 +    Disable = True;
 +EOF
 +</​sxh>​
 +
 +Agora vamos instalar o Vqadmin uma interface web para gerenciar os domínios e usuários ​
 +
 +Vamos preparar o vqadmin ​
 +<sxh bash>
 +
 +mkdir -p /​var/​www/​mail/​cgi-bin
 +cd /downloads/
 +tar zxvf vqadmin-2.3.7.tar.gz
 +cd /​downloads/​vqadmin-2.3.7
 +cp /​downloads/​vpopmail-5.4.33/​config.sub /​downloads/​vqadmin-2.3.7
 +</​sxh>​
 +
 +Agora vamos acertar a configuração do vqadmin
 +<sxh bash>
 +
 +./configure --enable-cgibindir=/​var/​www/​mail/​cgi-bin -enable-htmldir=/​var/​www/​mail/​ --enable-isoqlog=y
 +</​sxh>​
 +
 +Agora vamos mandar compilar e instalar ele
 +<sxh bash>
 +
 +make && make install-strip
 +</​sxh>​
 +
 +Agora vamos acertar a localização dele
 +<sxh bash>
 +
 +mv /images/ /​var/​www/​mail/​
 +ln -s /​var/​www/​mail/​images /​var/​www/​mail/​cgi-bin/​images
 +</​sxh>​
 +
 +Agora vamos acertar as permissões ​
 +<sxh bash>
 +cd /​var/​www/​mail/​cgi-bin/​vqadmin
 +chown www-data:​www-data .htaccess
 +chmod 644 .htaccess
 +</​sxh>​
 +
 +Agora vamos acertar o .htaccess ​
 +<sxh bash>
 +
 +vim /​var/​www/​mail/​cgi-bin/​vqadmin/​.htaccess
 +AuthType Basic
 +AuthUserFile /​var/​www/​mail/​cgi-bin/​vqadmin/​.htpasswd
 +AuthName vQadmin
 +require valid-user
 +satisfy any
 +</​sxh>​
 +
 +Agora vamos criar o usuário para poder ter acesso a interface ​
 +<sxh bash>
 +
 +htpasswd -bc /​var/​www/​mail/​cgi-bin/​vqadmin/​.htpasswd admin WEB_PASSWORD ​
 +</​sxh>​
 +
 +Agora vamos instalar o Qmailadmin ​
 +
 +Vamos preparar o qmailadmin ​
 +<sxh bash>
 +
 +cd /downloads/
 +tar zxvf qmailadmin-1.2.16.tar.gz
 +cd /​downloads/​qmailadmin-1.2.16
 +</​sxh>​
 +
 +Agora vamos configurar o qmailadmin
 +<sxh bash>
 +./configure --enable-cgibindir=/​var/​www/​mail/​cgi-bin/​ \
 +--enable-htmldir=/​var/​www/​mail/​cgi-bin/​ \
 +--enable-imageurl=../​../​images \
 +--enable-imagedir=/​var/​www/​mail/​images \
 +--enable-domain-autofill \
 +--enable-ezmlmdir=/​usr/​local/​bin/​ezmlm \
 +--enable-autoresponder-path=/​usr/​bin/​autorespond
 +</​sxh>​
 +
 +Agora vamos mandar compilar e instalar ele
 +<sxh bash>
 +
 +make && make install-strip
 +</​sxh>​
 +
 +Agora vamos fazer só um acerto de uma imagem do qmailadmin ​
 +<sxh bash>
 +
 +cd /​var/​www/​mail/​images
 +rm middleleft1.png
 +wget -c http://​wiki.douglasqsantos.com.br/​Downloads/​mail/​middleleft1.png
 +</​sxh>​
 +
 +Agora vamos criar um virtual host para utilizarmos o qmailadmin e o vqadmin ​
 +<sxh apache>
 +
 +vim /​etc/​apache2/​sites-available/​mailadmin.douglasqsantos.com.br
 +<​VirtualHost *:80>
 +        ServerAdmin webmaster@douglasqsantos.com.br
 +        DocumentRoot /​var/​www/​mail
 +        ServerName mailadmin.douglasqsantos.com.br
 +        Options -Indexes
 +        ErrorLog /​var/​log/​apache2/​mailadmin.douglasqsantos.com.br-error.log
 +        CustomLog /​var/​log/​apache2/​mailadmin.douglasqsantos.com.br-access.log common
 +
 +        <​Directory /​var/​www/​mail/​cgi-bin/>​
 +                Options ExecCGI FollowSymLinks -Indexes
 +                ForceType cgi-script
 +                AllowOverride All
 +                Order allow,deny
 +                Allow from all
 +        </​Directory>​
 +
 +        <​Directory /​var/​www/​mail/​cgi-bin/​vqadmin/>​
 +                deny from all
 +                Options ExecCGI -Indexes
 +                AllowOverride All
 +                Order deny,allow
 +        </​Directory>​
 +
 +        <​Directory /​var/​www/​mail/​qmailadmin/>​
 +                Options -Indexes
 +                Order allow,deny
 +                Allow from all
 +        </​Directory>​
 +
 +        <​Directory /​var/​www/​mail/​cgi-bin/​images/>​
 +                ForceType Off
 +                Options -Indexes
 +                Order allow,deny
 +                Allow from all
 +        </​Directory>​
 +
 +        <​Directory /​var/​www/​mail/​images/​qmailadmin/>​
 +                ForceType Off
 +                Options -Indexes
 +                Order allow,deny
 +                Allow from all
 +        </​Directory>​
 +
 +        <​Directory /​var/​www/​mail/​images/​vqadmin/>​
 +                ForceType Off
 +                Options -Indexes
 +                Order allow,deny
 +                Allow from all
 +        </​Directory>​
 +</​VirtualHost>​
 +</​sxh>​
 +
 +Agora vamos ativar o nosso virtualhost ​
 +<sxh bash>
 +
 +a2ensite mailadmin.douglasqsantos.com.br
 +</​sxh>​
 +
 +Agora vamos recarregar o Apache
 +<sxh bash>
 +
 +/​etc/​init.d/​apache2 reload
 +</​sxh>​
 +
 +Para acessar ou insira a entrada do mailadmin no seu servidor dns ou edite o arquivo /etc/hosts da seguinte forma no cliente que vai acessar o mailadmin ​
 +<sxh bash>
 +
 +ip_servidor mailadmin.douglasqsantos.com.br mailadmin
 +</​sxh>​
 +
 +
 +Agora podemos acessar o vqadmin em http://​mailadmin.douglasqsantos.com.br/​cgi-bin/​vqadmin/​vqadmin.cgi para testar o vqadmin (login: admin e a senha que foi setada com o httpasswd -bc no meu caso WEB_PASSWORD ) 
 +
 +**OBS:** O domínio e o usuário vão ser criados mais a frente ​
 +
 +Para acessar o qmailadmin http://​mailadmin.douglasqsantos.com.br/​cgi-bin/​qmailadmin aqui informe o usuário sendo postmaster o domínio douglasqsantos.com.br e a senha POSTMASTER_PASSWORD ​
 +
 +
 +Agora vamos remover o MTA instalado o Exim é o MTA default do Debian. ​
 +<sxh bash>
 +
 +/​etc/​init.d/​exim4 stop
 +dpkg --ignore-depends=exim4 -r exim4
 +dpkg --ignore-depends=exim4-daemon-light -r exim4-daemon-light
 +</​sxh>​
 +
 +Caso tenha o postfix instalado podemos remover ele da seguinte forma 
 +<sxh bash>
 +
 +dpkg --purge --ignore-depends=postfix postfix
 +</​sxh>​
 +
 +Caso tenha o sendmail instalado podemos remover ele da seguinte forma 
 +<sxh bash>
 +
 +dpkg --purge sendmail sendmail-base sendmail-bin sendmail-cf
 +</​sxh>​
 +
 +Agora vamos instalar um MTA generico para o Debian não reclamar ​
 +<sxh bash>
 +
 +dpkg -i /​downloads/​deb-packages/​mta-local_1.0_all.deb
 +</​sxh>​
 +
 +Agora vamos criar alguns links para podermos utilizar o Qmail como MTA default ​
 +<sxh bash>
 +
 +rm -f /​usr/​lib/​sendmail
 +rm -f /​usr/​sbin/​sendmail
 +ln -s /​var/​qmail/​bin/​sendmail /​usr/​lib/​sendmail
 +ln -s /​var/​qmail/​bin/​sendmail /​usr/​sbin/​sendmail
 +</​sxh>​
 +
 +Agora vamos acertar a configuração do Qmail 
 +
 +Agora vamos copiar o arquivo de inicialização do qmailctl ​
 +<sxh bash>
 +
 +cp /​downloads/​scripts/​qmailctl /​var/​qmail/​bin/​qmailctl
 +chmod 755 /​var/​qmail/​bin/​qmailctl
 +</​sxh>​
 +
 +Agora vamos criar um link simbolico do qmailctl ​
 +<sxh bash>
 +
 +ln -s /​var/​qmail/​bin/​qmailctl /usr/bin
 +</​sxh>​
 +
 +Agora vamos setar o Maildir como padrão ​
 +<sxh bash>
 +
 +echo ./Maildir > /​var/​qmail/​control/​defaultdelivery
 +</​sxh>​
 +
 +Agora vou acertar mais alguns arquivos que podem ser obtidas informações em http://​www.lifewithqmail.com/​lwq.html#​configuration ​
 +<sxh bash>
 +echo 255 > /​var/​qmail/​control/​concurrencyremote
 +echo 30 > /​var/​qmail/​control/​concurrencyincoming
 +echo 30 > /​var/​qmail/​control/​timeoutsmtpd
 +echo 3 > /​var/​qmail/​control/​spfbehavior
 +echo postmaster@douglasqsantos.com.br > /​var/​qmail/​control/​bouncefrom
 +echo douglasqsantos.com.br > /​var/​qmail/​control/​doublebouncehost
 +echo postmaster > /​var/​qmail/​control/​doublebounceto
 +</​sxh>​
 +
 +
 +Agora vamos acertar as permissões dos arquivos ​
 +<sxh bash>
 + 
 +cd /​var/​qmail/​control/​
 +chmod 644 bouncefrom doublebouncehost doublebounceto concurrencyremote concurrencyincoming spfbehavior
 +</​sxh>​
 +
 +Vamos definir o tamanho máximo da mensagem para 8Mb 
 +<sxh bash>
 +
 +echo '​8000000'​ > /​var/​qmail/​control/​databytes ​
 +</​sxh>​
 +
 +Vamos habilitar o localhost para enviar email 
 +<sxh bash>
 +
 +echo '​127.:​allow,​RELAYCLIENT=""'​ >> /​etc/​tcp.smtp
 +qmailctl cdb
 +</​sxh>​
 +
 +Agora vamos acertar os alias, eles são apelidos para alguns email como root@dominio.com.br ou postmaster@dominio.com.br ​
 +<sxh bash>
 +
 +echo douglas@douglasqsantos.com.br > /​var/​qmail/​alias/​.qmail-root
 +echo douglas@douglasqsantos.com.br > /​var/​qmail/​alias/​.qmail-postmaster
 +echo douglas@douglasqsantos.com.br > /​var/​qmail/​alias/​.qmail-mailer-daemon
 +</​sxh>​
 +
 +Agora vamos acertar as permissões dos alias 
 +<sxh bash>
 +
 +chmod 644 /​var/​qmail/​alias/​.qmail*
 +</​sxh>​
 +
 +Vamos acertar as ultimas configurações ​
 +<sxh bash>
 +
 +cd /​usr/​src/​qmail/​qmail-1.03
 +./​config-fast mail.douglasqsantos.com.br
 +Your fully qualified host name is mail.douglasqsantos.com.br.
 +Putting mail.douglasqsantos.com.br into control/​me...
 +Putting douglasqsantos.com.br into control/​defaultdomain...
 +Putting wiki.br into control/​plusdomain...
 +Putting mail.douglasqsantos.com.br into control/​locals...
 +Putting mail.douglasqsantos.com.br into control/​rcpthosts...
 +Now qmail will refuse to accept SMTP messages except to mail.douglasqsantos.com.br.
 +Make sure to change rcpthosts if you add hosts to locals or virtualdomains
 +</​sxh>​
 +
 +Vamos fazer o último acerto ​
 +<sxh bash>
 +
 +cat /dev/null > /​var/​qmail/​control/​locals
 +</​sxh>​
 +
 +Agora vamos configurar o Daemontools que vai ser quem comando os scripts do qmail 
 +<sxh bash>
 +
 +mkdir -p /​var/​qmail/​supervise/​qmail-smtpd/​log
 +mkdir -p /​var/​qmail/​supervise/​qmail-send/​log
 +mkdir -p /​var/​qmail/​supervise/​qmail-smtpdssl/​log
 +cd /​var/​qmail/​supervise
 +chmod +t qmail-smtpd qmail-send qmail-smtpdssl
 +</​sxh>​
 +
 +Agora vamos copiar os arquivos que controlam os serviços do qmail para as suas localizações ​
 +<sxh bash>
 +
 +cp /​downloads/​scripts/​service-qmail-send-run /​var/​qmail/​supervise/​qmail-send/​run
 +cp /​downloads/​scripts/​send_log /​var/​qmail/​supervise/​qmail-send/​log/​run
 +cp /​downloads/​scripts/​service-qmail-smtpd-run /​var/​qmail/​supervise/​qmail-smtpd/​run
 +cp /​downloads/​scripts/​smtpd_log /​var/​qmail/​supervise/​qmail-smtpd/​log/​run
 +cp /​downloads/​scripts/​service-qmail-smtpdssl-run /​var/​qmail/​supervise/​qmail-smtpdssl/​run
 +cp /​downloads/​scripts/​smtpdssl_log /​var/​qmail/​supervise/​qmail-smtpdssl/​log/​run
 +</​sxh>​
 +
 +Vamos acertar as permissões ​
 +<sxh bash>
 +
 +chmod 751 /​var/​qmail/​supervise/​qmail-smtpd/​run
 +chmod 751 /​var/​qmail/​supervise/​qmail-smtpd/​log/​run
 +chmod 751 /​var/​qmail/​supervise/​qmail-send/​run
 +chmod 751 /​var/​qmail/​supervise/​qmail-send/​log/​run
 +chmod 751 /​var/​qmail/​supervise/​qmail-smtpdssl/​run
 +chmod 751 /​var/​qmail/​supervise/​qmail-smtpdssl/​log/​run
 +</​sxh>​
 +
 +Vamos acertar os links para os serviços ​
 +<sxh bash>
 +
 +ln -s /​var/​qmail/​supervise/​qmail-send /​var/​qmail/​supervise/​qmail-smtpd /​var/​qmail/​supervise/​qmail-smtpdssl /​etc/​service
 +</​sxh>​
 +
 +Agora vamos acertar mais um link para acertar o sistema
 +<sxh bash>
 +
 +ln -s /​etc/​service /service
 +</​sxh>​
 +
 +Agora vamos configurar o SpamAssassin ​
 +<sxh bash>
 +
 +vim /​etc/​default/​spamassassin
 +[...]
 +ENABLED=1
 +OPTIONS="​--create-prefs --max-children 5 --helper-home-dir -u vpopmail -v -x -i -m 5 -c -H -s mail"
 +</​sxh>​
 +
 +Vamos fazer mais acerto sobre os agentes auxiliares para o SpamAssassin ​
 +<sxh bash>
 +
 +vim /​etc/​spamassassin/​local.cf
 +[...]
 +#Descomente as seguintes linhas
 +required_score 5.0
 +use_bayes 1
 +bayes_auto_learn 1
 +
 +#Adicione as seguintes linhas
 +use_razor2 1
 +skip_rbl_checks 1
 +use_dcc 1
 +use_pyzor 1
 +pyzor_options --homedir /​etc/​spamassassin/​
 +razor_config /​etc/​razor/​razor-agent.conf
 +</​sxh>​
 +
 +Agora vamos acertar o pyzor 
 +<sxh bash>
 +
 +pyzor --homedir /​etc/​spamassassin discover ​
 +</​sxh>​
 +
 +Agora vamos acertar o razor 
 +<sxh bash>
 +
 +razor-admin -d -home=/​etc/​razor -create
 +razor-admin -d -home=/​etc/​razor -register
 +</​sxh>​
 +
 +Vamos habilibar um plugin do SpamAssassin ​
 +<sxh bash>
 +
 +vim /​etc/​spamassassin/​v310.pre
 +[...]
 +#Descomente a seguinte linha
 +loadplugin Mail::​SpamAssassin::​Plugin::​DCC ​
 +</​sxh>​
 +
 +Vamos habilitar mais um plugin do SpamAssassin ​
 +<sxh bash>
 +
 +vim /​etc/​spamassassin/​v320.pre
 +[...]
 +#Descomente a seguinte linha
 +loadplugin Mail::​SpamAssassin::​Plugin::​Rule2XSBody ​
 +</​sxh>​
 +
 +Vamos instalar mais uma dependência para o nosso Spamassassin ​
 +<sxh bash>
 +
 +dpkg -i /​downloads/​deb-packages/​libip-country-perl_2.27-1_all.deb ​
 +</​sxh>​
 +
 +Agora vamos habilitar mais um plugin ​
 +<sxh bash>
 +
 +vim /​etc/​spamassassin/​init.pre
 +[...]
 +#Descomente a seguinte linha
 +loadplugin Mail::​SpamAssassin::​Plugin::​RelayCountry ​
 +</​sxh>​
 +
 +Agora vamos compilar as regras do SpamAssassin ​
 +<sxh bash>
 +
 +sa-compile ​
 +</​sxh>​
 +
 +Agora vamos testar o SpamAssassin ​
 +<sxh bash>
 +
 +/​usr/​bin/​spamassassin -D --lint
 +</​sxh>​
 +
 +Agora vamos reiniciar o SpamAssassin
 +<sxh bash>
 +
 +/​etc/​init.d/​spamassassin start
 +</​sxh>​
 +
 +Agora vamos configurar o Clamav ​
 +<sxh bash>
 +dpkg-reconfigure clamav-base
 +#Aqui temos que determinar que o usuário e grupo vai ser o qscand outras configurações podem ser selecionadas as opções padrões.
 +</​sxh>​
 +
 +Agora vamos configurar o freshclam ​
 +<sxh bash>
 +dpkg-reconfigure clamav-freshclam
 +#Aqui escolha daemon + Agora selecione o repositório Brasil + as outras perguntas deixe as opções default ​
 +</​sxh>​
 +
 +Agora vamos acertar as permissões ​
 +<sxh bash>
 +chown -R qscand:​clamav /​var/​log/​clamav /​var/​lib/​clamav /​var/​run/​clamav
 +chown qscand:​qscand /​etc/​clamav/​freshclam.conf
 +chmod 600 /​etc/​clamav/​freshclam.conf
 +ln -s /​var/​log/​clamav /​var/​log/​qmail/​clamav
 +</​sxh>​
 +
 +Vamos fazer mais alguns acertos o freshclam ​
 +<sxh bash>
 +
 +sed -i '​s/​DatabaseOwner clamav/​DatabaseOwner qscand/'​ /​etc/​clamav/​freshclam.conf
 +sed -i '​s/​clamav adm/qscand qscand/'​ /​etc/​logrotate.d/​clamav-freshclam
 +sed -i '​s/​clamav adm/qscand qscand/'​ /​etc/​logrotate.d/​clamav-daemon
 +</​sxh>​
 +
 +Agora vamos reiniciar os serviços ​
 +<sxh bash>
 +
 +/​etc/​init.d/​clamav-daemon restart
 +/​etc/​init.d/​clamav-freshclam restart
 +</​sxh>​
 +
 +Agora vamos configurar o Courier ​
 +
 +Agora vamos acertar a configuração das chaves ​
 +
 +Vamos acertar a configuração da geração da chave para o imap
 +<sxh bash>
 +
 +vim /​etc/​courier/​imapd.cnf
 +[...]
 +[ req_dn ]
 +C=BR
 +ST=PR
 +L=Curitiba
 +O=Courier Mail Server
 +OU=Automatically-generated IMAP SSL key
 +CN=mail.douglasqsantos.com.br
 +emailAddress=postmaster@douglasqsantos.com.br
 +[...]
 +</​sxh>​
 +
 +Vamos acertar a configuração da geração da chave para o pop
 +<sxh bash>
 +vim /​etc/​courier/​pop3d.cnf
 +[...]
 +[ req_dn ]
 +C=BR
 +ST=PR
 +L=Curitiba
 +O=Courier Mail Server
 +OU=Automatically-generated POP3 SSL key
 +CN=mail.douglasqsantos.com.br
 +emailAddress=postmaster@douglasqsantos.com.br
 +[...]
 +</​sxh>​
 +
 +Agora vamos remover as chaves antigas ​
 +<sxh bash>
 +
 +rm -f /​usr/​lib/​courier/​*.pem
 +rm -f /​etc/​courier/​*.pem
 +</​sxh>​
 +
 +Vamos fazer um acerto na quantidade de dias que o certificado vai estar valido ​
 +<sxh bash>
 +
 +sed -i '​s/​-days 365/-days 3650/' /​usr/​lib/​courier/​mkimapdcert
 +sed -i '​s/​-days 365/-days 3650/' /​usr/​lib/​courier/​mkpop3dcert
 +</​sxh>​
 +
 +Agora vamos gerar novamente os certificados ​
 +<sxh bash>
 +
 +dpkg-reconfigure courier-imap-ssl
 +dpkg-reconfigure courier-pop-ssl
 +</​sxh>​
 +
 +Agora vamos criar um link para a localização das chaves ​
 +<sxh bash>
 +ln -s /​usr/​lib/​courier/​pop3d.pem /​etc/​courier/​pop3d.pem
 +ln -s /​usr/​lib/​courier/​imapd.pem /​etc/​courier/​imapd.pem ​
 +</​sxh>​
 +
 +Agora vamos configurar o courier-authlib para poder obter as informações de usuários e domínios no MySQL 
 +
 +Primeiro vamos acertar qual módulo devemos utilizar na autenticação ​
 +<sxh bash>
 +
 +vim /​etc/​courier/​authdaemonrc
 +[...]
 +authmodulelist="​authmysql" ​
 +</​sxh>​
 +
 +Agora vamos acertar a conexão do courier com a base de dados deixe o arquivo como abaixo
 +<sxh bash>
 +
 +vim /​etc/​courier/​authmysqlrc
 +MYSQL_SERVER ​       localhost
 +MYSQL_USERNAME ​     vpopmailuser
 +MYSQL_PASSWORD ​     VPOPMAIL_PASSWORD
 +MYSQL_DATABASE ​     vpopmail
 +MYSQL_SELECT_CLAUSE ​   SELECT CONCAT(pw_name,​ '​@',​ pw_domain) AS username, ​   \
 +            pw_passwd AS cryptpw, ​                   \
 +            pw_clear_passwd AS clearpw, ​               \
 +            '​89'​ AS uid,                        \
 +            '​89'​ AS gid,                        \
 +            pw_dir AS home,                        \
 +            ''​ AS maildir, ​                       \
 +            pw_shell AS quota, ​                       \
 +            pw_gecos AS fullname, ​                   \
 +            '​disablewebmail=0,​disablepop3=0,​disableimap=0'​ AS options ​   \
 +            FROM vpopmail ​                       \
 +            WHERE                            \
 +            pw_name = '​$(local_part)' ​               \
 +            AND                            \
 +            pw_domain = '​$(domain)'; ​               \
 +</​sxh>​
 +
 +Agora vamos reiniciar o serviço ​
 +<sxh bash>
 +
 +/​etc/​init.d/​courier-authdaemon restart ​
 +</​sxh>​
 +
 +Agora vamos instalar o qmail-scanner ​
 +
 +Vamos acertar o pacote ​
 +<sxh bash>
 +
 +cd /downloads/
 +tar zxvf q-s-2.08st-20100626.tgz
 +cd /​downloads/​qmail-scanner-2.08st
 +</​sxh>​
 +
 +Vamos preparar o pacote a configuração do qmail-scanner
 +<sxh bash>
 +
 +./configure --admin postmaster --domain douglasqsantos.com.br --local-domains "​douglasqsantos.com.br"​ --sa-quarantine 5 --ignore-eol-check yes --add-dscr-hdrs yes --notify psender,​admin --sa-report yes --fix-mime 1 --unzip 1 --archive 0 --silent-viruses auto --redundant no --log-crypto 0
 +</​sxh>​
 +
 +Vamos compilar o pacote ​
 +<sxh bash>
 +
 +./configure --admin postmaster --domain douglasqsantos.com.br --local-domains "​douglasqsantos.com.br"​ --sa-quarantine 5 --ignore-eol-check yes --add-dscr-hdrs yes --notify psender,​admin --sa-report yes --fix-mime 1 --unzip 1 --archive 0 --silent-viruses auto --redundant no --log-crypto 0 --install 1
 +</​sxh>​
 +
 +Vamos acertar o link para o qscan 
 +<sxh bash>
 +
 +ln -s /​var/​spool/​qscan /​var/​log/​qmail/​qscan
 +</​sxh>​
 +
 +Agora vamos que efetuar um teste com um usuário comum 
 +<sxh bash>
 +
 +su - douglas
 +/​var/​qmail/​bin/​qmail-scanner-queue.pl -g
 +perlscanner:​ generate new DB file from /​var/​spool/​qscan/​quarantine-events.txt
 +perlscanner:​ total of 35 entries.
 +exit
 +</​sxh>​
 +
 +Agora vamos acertar o logrotate para qmail-scanner ​
 +<sxh bash>
 +
 +cp /​downloads/​qmail-scanner-2.08st/​contrib/​logrotate.qmail-scanner /​etc/​logrotate.d/​qmail-scanner
 +chmod 644 /​etc/​logrotate.d/​qmail-scanner ​
 +</​sxh>​
 +
 +Vamos reiniciar o qmail 
 +<sxh bash>
 +
 +qmailctl restart
 +Restarting qmail:
 +* Stopping qmail-smtpdssl.
 +* Stopping qmail-smtpd.
 +* Sending qmail-send SIGTERM and restarting.
 +* Restarting qmail-smtpd.
 +* Restarting qmail-smtpdssl.
 +</​sxh>​
 +
 +Agora vamos ver o status do qmail 
 +<sxh bash>
 +
 +qmailctl stat
 +/​service/​qmail-send:​ up (pid 13716) 31 seconds
 +/​service/​qmail-send/​log:​ up (pid 13712) 31 seconds
 +/​service/​qmail-smtpd:​ up (pid 13713) 31 seconds
 +/​service/​qmail-smtpd/​log:​ up (pid 13715) 31 seconds
 +/​service/​qmail-smtpdssl:​ up (pid 13710) 31 seconds
 +/​service/​qmail-smtpdssl/​log:​ up (pid 13711) 31 seconds
 +messages in queue: 0
 +messages in queue but not yet preprocessed:​ 0
 +</​sxh>​
 +
 +Se o algum serviço ficar em 1 segundo verefique nos seguintes arquivos ​
 +<sxh bash>
 +
 +tail /​var/​log/​qmail/​qmail-send/​current
 +tail /​var/​log/​qmail/​qmail-smtpd/​current
 +tail /​var/​log/​qmail/​qmail-smtpdssl/​current
 +</​sxh>​
 +
 +Agora vamos testar a conbinação do qmail-scanner + spamassassin + clamav ​
 +<sxh bash>
 +
 +cd /​downloads/​qmail-scanner-2.08st/​contrib
 +chmod 755 test_installation.sh
 +./​test_installation.sh -doit
 +Sending standard test message - no viruses... 1/4
 +done
 +
 +Sending eicar test virus - should be caught by perlscanner module... 2/4
 +done
 +
 +Sending eicar test virus with altered filename - should only be caught by commercial anti-virus modules (if you have any)... 3/4
 +done
 +
 +Sending bad spam message for anti-spam testing - In case you are using SpamAssassin... 4/4
 +
 +
 +If you have enabled $sa_quarantine,​ $sa_delete or $sa_reject the
 +spam-message wont't arrive to the recipients. But if you have enabled
 +(good idea) '​debug'​ you should check
 +/​var/​spool/​qscan/​qmail-queue.log (or where ever you have the log).
 +
 +
 +  Done
 +
 +Finished test. Now go and check Email sent to postmaster@douglasqsantos.com.br and/or the log..
 +</​sxh>​
 +
 +Agora vamos ver as estatísticas ​
 +<sxh bash>
 +
 +/​var/​spool/​qscan/​log-report.sh /​var/​spool/​qscan/​qmail-queue.log ​
 +
 +      5 Messages processed
 +      1 Virus Eicar-Test-Signature
 +      1 Spam quarantined
 +      1 Policy blocked
 +</​sxh>​
 +
 +Agora vamos criar uma tarefa para sempre receber as estastísticas ​ por email 
 +<sxh bash>
 +
 +echo '/​var/​spool/​qscan/​log-report.sh /​var/​spool/​qscan/​qmail-queue.log |mail douglas@douglasqsantos.com.br'​ > /​etc/​cron.daily/​qmailscanner-report
 +chmod 755 /​etc/​cron.daily/​qmailscanner-report
 +</​sxh>​
 +
 +Agora vamos testar a nossa instalação Qmail 
 +<sxh bash>
 +
 +chmod +x /​downloads/​scripts/​qmr_inst_check
 +/​downloads/​scripts/​qmr_inst_check ​
 +Congratulations,​ your updated Debian Qmailrocks installation looks good
 +</​sxh>​
 +
 +Vamos criar um domínio para podermos ter acesso ao qmailadmin ​
 +<sxh bash>
 +
 +/​home/​vpopmail/​bin/​vadddomain douglasqsantos.com.br POSTMASTER_PASSWORD
 +</​sxh>​
 +
 +Vamos cadastrar um usuário para testar ​
 +<sxh bash>
 +
 +/​home/​vpopmail/​bin/​vadduser -q 10M douglas@douglasqsantos.com.br doug123
 +</​sxh>​
 +
 +Vamos agorar ver se o usuário foi criado corretamente ​
 +<sxh bash>
 +
 +/​home/​vpopmail/​bin/​vuserinfo douglas@douglasqsantos.com.br
 +name:   ​douglas
 +passwd: $1$OLJCBol7$6/​ER8xWUHsJd1spK5hdG70
 +clear passwd: doug123
 +comment/​gecos:​ douglas
 +uid:    0
 +gid:    0
 +flags: ​ 0
 +gecos: douglas
 +limits: No user limits set.
 +dir:       /​home/​vpopmail/​domains/​douglasqsantos.com.br/​douglas
 +quota: ​    ​10485760S
 +usage: ​    0%
 +account created: Thu Nov 10 12:17:45 2011
 +last auth: Never logged in
 +</​sxh>​
 +
 +Agora vamos recarregar o nosso qmail 
 +<sxh bash>
 +
 +qmailctl reload
 +Sending HUP signal to qmail-send.
 +</​sxh>​
 +
 +
 +Agora vamos efetuar um teste de envio de email 
 +<sxh bash>
 +
 +telnet localhost 25
 +Trying 127.0.0.1...
 +Connected to localhost.
 +Escape character is '​^]'​.
 +220 mail.douglasqsantos.com.br ESMTP
 +EHLO mail.douglasqsantos.com.br
 +250-mail.douglasqsantos.com.br
 +250-STARTTLS
 +250-SIZE 8000000
 +250-PIPELINING
 +250 8BITMIME
 +MAIL FROM: <​douglas@douglasqsantos.com.br>​
 +250 ok
 +RCPT TO: <​douglas@douglasqsantos.com.br>​
 +250 ok
 +DATA
 +354 go ahead
 +FROM: Douglas <​douglas@douglasqsantos.com.br>​
 +TO: Douglas <​douglas@douglasqsantos.com.br> ​         ​
 +Subject: Teste de Envio de Email
 +Efetuando um teste de Envio de Email 
 +.
 +250 ok 1320935956 qp 14736
 +quit
 +221 mail.douglasqsantos.com.br
 +Connection closed by foreign host.
 +</​sxh>​
 +
 +Agora vamos visualizar a nossa mensagem ​
 +<sxh bash>
 +
 +cat /​home/​vpopmail/​domains/​douglasqsantos.com.br/​douglas/​Maildir/​new/​*
 +Return-Path:​ <​douglas@douglasqsantos.com.br>​
 +Delivered-To:​ douglas@douglasqsantos.com.br
 +Received: (qmail 14752 invoked by uid 168); 10 Nov 2011 12:39:16 -0200
 +Received: from localhost by mail (envelope-from <​douglas@douglasqsantos.com.br>,​ uid 89) with qmail-scanner-2.08st ​
 + ​(clamdscan:​ 0.97.3/​13913. spamassassin:​ 3.3.1. perlscan: 2.08st.  ​
 + ​Clear:​RC:​1(127.0.0.1):​. ​
 + ​Processed in 0.010451 secs); 10 Nov 2011 14:39:16 -0000
 +Received: from localhost (HELO mail.douglasqsantos.com.br) (127.0.0.1)
 +  by mail.douglasqsantos.com.br with SMTP; 10 Nov 2011 12:38:47 -0200
 +FROM: Douglas <​douglas@douglasqsantos.com.br>​
 +TO: Douglas <​douglas@douglasqsantos.com.br>​
 +Subject: Teste de Envio de Email
 +Efetuando um teste de Envio de Email 
 +</​sxh>​
 +
 +
 +Agora vamos testar o starttls ​
 +<sxh bash>
 +
 +telnet localhost 25
 +Trying 127.0.0.1...
 +Connected to localhost.
 +Escape character is '​^]'​.
 +220 mail.douglasqsantos.com.br ESMTP
 +EHLO mail.douglasqsantos.com.br
 +250-mail.douglasqsantos.com.br
 +250-STARTTLS
 +250-SIZE 8000000
 +250-PIPELINING
 +250 8BITMIME
 +starttls
 +220 ready for tls
 +quit
 +quit
 +Connection closed by foreign host.
 +</​sxh>​
 +
 +
 +Agora vamos testar a autenticação com TLS 
 +
 +Vamos gerar em base64 o usuário e a senha 
 +<sxh bash>
 +#perl
 +perl /​downloads/​scripts/​base64
 +Press Enter to exit. 
 +Input you string: douglas@douglasqsantos.com.br
 +Base64 encode is : ZG91Z2xhc0Bkb3VnbGFzLndpa2kuYnI=
 +Input you string: doug123
 +Base64 encode is : ZG91ZzEyMw=====
 +Input you string: ^C
 +</​sxh>​
 +
 +Agora vamos efetuar um teste de startls ​
 +<sxh bash>
 +
 +openssl s_client -starttls smtp -crlf -connect localhost:​25 -quiet ​
 +depth=0 /​C=BR/​ST=Parana/​L=Curitiba/​O=Douglas/​OU=TI/​CN=mail.douglasqsantos.com.br/​emailAddress=postmaster@douglasqsantos.com.br
 +verify error:​num=18:​self signed certificate
 +verify return:1
 +depth=0 /​C=BR/​ST=Parana/​L=Curitiba/​O=Douglas/​OU=TI/​CN=mail.douglasqsantos.com.br/​emailAddress=postmaster@douglasqsantos.com.br
 +verify return:1
 +250 8BITMIME
 +EHLO mail.douglasqsantos.com.br
 +250-mail.douglasqsantos.com.br
 +250-AUTH LOGIN PLAIN
 +250-AUTH=LOGIN PLAIN
 +250-SIZE 8000000
 +250-PIPELINING
 +250 8BITMIME
 +auth login
 +334 VXNlcm5hbWU6
 +ZG91Z2xhc0Bkb3VnbGFzLndpa2kuYnI=
 +334 UGFzc3dvcmQ6
 +ZG91ZzEyMw=====
 +235 ok, go ahead (#2.0.0)
 +MAIL FROM: <​douglas@douglasqsantos.com.br>​
 +250 ok
 +RCPT TO: <​douglas@douglasqsantos.com.br>​
 +250 ok
 +DATA
 +354 go ahead
 +From: Douglas <​douglas@douglasqsantos.com.br>​
 +To: Douglas <​douglas@douglasqsantos.com.br>​
 +Subject: Teste de envio de Email
 +
 +Teste de Envio de Email por TLS
 +.
 +250 ok 1320935255 qp 14480
 +quit
 +221 mail.douglasqsantos.com.br
 +</​sxh>​
 +
 +Vamos visualizar a nossa mensagem ​
 +<sxh bash>
 +
 +cat /​home/​vpopmail/​domains/​douglasqsantos.com.br/​douglas/​Maildir/​new/​*
 +[...]
 +Return-Path:​ <​douglas@douglasqsantos.com.br>​
 +Delivered-To:​ douglas@douglasqsantos.com.br
 +Received: (qmail 14834 invoked by uid 168); 10 Nov 2011 12:42:23 -0200
 +Received: from localhost (douglas@douglasqsantos.com.br@localhost) by mail (envelope-from <​douglas@douglasqsantos.com.br>,​ uid 89) with qmail-scanner-2.08st ​
 + ​(clamdscan:​ 0.97.3/​13913. spamassassin:​ 3.3.1. perlscan: 2.08st.  ​
 + ​Clear:​RC:​1(127.0.0.1):​. ​
 + ​Processed in 2.954303 secs); 10 Nov 2011 14:42:23 -0000
 +Received: from localhost (HELO mail.douglasqsantos.com.br) (douglas@douglasqsantos.com.br@127.0.0.1)
 +  by mail.douglasqsantos.com.br with AES256-SHA encrypted SMTP; 10 Nov 2011 12:42:10 -0200
 +From: Douglas <​douglas@douglasqsantos.com.br>​
 +To: Douglas <​douglas@douglasqsantos.com.br>​
 +Subject: Teste de envio de Email
 +Message-ID: <​1320936140101814826@mail>​
 +
 +Teste de Envio de Email por TLS
 +</​sxh>​
 +
 +Agora vamos efetuar um teste de SMTP-SSL ​
 +<sxh bash>
 +
 +openssl s_client -crlf -connect localhost:​465 -quiet ​
 +depth=0 /​C=BR/​ST=Parana/​L=Curitiba/​O=Douglas/​OU=TI/​CN=mail.douglasqsantos.com.br/​emailAddress=postmaster@douglasqsantos.com.br
 +verify error:​num=18:​self signed certificate
 +verify return:1
 +depth=0 /​C=BR/​ST=Parana/​L=Curitiba/​O=Douglas/​OU=TI/​CN=mail.douglasqsantos.com.br/​emailAddress=postmaster@douglasqsantos.com.br
 +verify return:1
 +220 mail.douglasqsantos.com.br ESMTP
 +EHLO mail.douglasqsantos.com.br
 +250-mail.douglasqsantos.com.br
 +250-AUTH LOGIN PLAIN
 +250-AUTH=LOGIN PLAIN
 +250-SIZE 8000000
 +250-PIPELINING
 +250 8BITMIME
 +auth login
 +334 VXNlcm5hbWU6
 +ZG91Z2xhc0Bkb3VnbGFzLndpa2kuYnI=
 +334 UGFzc3dvcmQ6
 +ZG91ZzEyMw=====
 +235 ok, go ahead (#2.0.0)
 +MAIL FROM: <​postmaster@douglasqsantos.com.br>​
 +250 ok
 +RCPT TO: <​postmaster@douglasqsantos.com.br>​
 +250 ok
 +DATA
 +354 go ahead
 +From: Douglas <​postmaster@douglasqsantos.com.br>​
 +To: Douglas <​postmaster@douglasqsantos.com.br>​
 +Subject: Teste de Envio de Email SMTP-SSL
 +
 +Teste de SMTP-SSL
 +.
 +250 ok 1320936465 qp 14846
 +quit
 +221 mail.douglasqsantos.com.br
 +</​sxh>​
 +
 +Agora vamos visualizar a nossa mensagem ​
 +<sxh bash>
 +
 +cat /​home/​vpopmail/​domains/​douglasqsantos.com.br/​postmaster/​Maildir/​new/​*
 +Return-Path:​ <​postmaster@douglasqsantos.com.br>​
 +Delivered-To:​ postmaster@douglasqsantos.com.br
 +Received: (qmail 14846 invoked by uid 89); 10 Nov 2011 12:46:55 -0200
 +Received: from localhost (HELO mail.douglasqsantos.com.br) (douglas@douglasqsantos.com.br@127.0.0.1)
 +  by mail.douglasqsantos.com.br with SMTP; 10 Nov 2011 12:46:55 -0200
 +From: Douglas <​postmaster@douglasqsantos.com.br>​
 +To: Douglas <​postmaster@douglasqsantos.com.br>​
 +Subject: Teste de Envio de Email SMTP-SSL
 +
 +Teste de SMTP-SSL
 +</​sxh>​
 +
 +Agora vamos efetuar o teste de autenticação com Pop3 
 +<sxh bash>
 +
 +telnet localhost 110
 +Trying 127.0.0.1...
 +Connected to localhost.
 +Escape character is '​^]'​.
 ++OK Hello there.
 +user douglas@douglasqsantos.com.br
 ++OK Password required.
 +pass doug123
 ++OK logged in.
 +#Listando as mensagens
 +list
 ++OK POP3 clients that break here, they violate STD53.
 +1 700
 +2 817
 +.
 +#Mandando ler a mensagem 1
 +retr 1
 ++OK 700 octets follow.
 +Return-Path:​ <​douglas@douglasqsantos.com.br>​
 +Delivered-To:​ douglas@douglasqsantos.com.br
 +Received: (qmail 14752 invoked by uid 168); 10 Nov 2011 12:39:16 -0200
 +Received: from localhost by mail (envelope-from <​douglas@douglasqsantos.com.br>,​ uid 89) with qmail-scanner-2.08st ​
 + ​(clamdscan:​ 0.97.3/​13913. spamassassin:​ 3.3.1. perlscan: 2.08st.  ​
 + ​Clear:​RC:​1(127.0.0.1):​. ​
 + ​Processed in 0.010451 secs); 10 Nov 2011 14:39:16 -0000
 +Received: from localhost (HELO mail.douglasqsantos.com.br) (127.0.0.1)
 +  by mail.douglasqsantos.com.br with SMTP; 10 Nov 2011 12:38:47 -0200
 +FROM: Douglas <​douglas@douglasqsantos.com.br>​
 +TO: Douglas <​douglas@douglasqsantos.com.br>​
 +Subject: Teste de Envio de Email
 +Efetuando um teste de Envio de Email 
 +.
 +quit
 ++OK Bye-bye.
 +Connection closed by foreign host.
 +</​sxh>​
 +
 +Agora vamos testar a autenticação do pop3 com SSL 
 +<sxh bash>
 +
 +openssl s_client -connect localhost:​995 -quiet ​
 +depth=0 /​C=US/​ST=NY/​L=New York/​O=Courier Mail Server/​OU=Automatically-generated POP3 SSL key/​CN=localhost/​emailAddress=postmaster@example.com
 +verify error:​num=18:​self signed certificate
 +verify return:1
 +depth=0 /​C=US/​ST=NY/​L=New York/​O=Courier Mail Server/​OU=Automatically-generated POP3 SSL key/​CN=localhost/​emailAddress=postmaster@example.com
 +verify return:1
 ++OK Hello there.
 +user douglas@douglasqsantos.com.br
 ++OK Password required.
 +pass doug123
 ++OK logged in.
 +#listando as mensagens
 +list
 ++OK POP3 clients that break here, they violate STD53.
 +1 700
 +2 817
 +.
 +#Mandando ler a mensagem 2
 +retr 2
 ++OK 817 octets follow.
 +Return-Path:​ <​douglas@douglasqsantos.com.br>​
 +Delivered-To:​ douglas@douglasqsantos.com.br
 +Received: (qmail 14834 invoked by uid 168); 10 Nov 2011 12:42:23 -0200
 +Received: from localhost (douglas@douglasqsantos.com.br@localhost) by mail (envelope-from <​douglas@douglasqsantos.com.br>,​ uid 89) with qmail-scanner-2.08st ​
 + ​(clamdscan:​ 0.97.3/​13913. spamassassin:​ 3.3.1. perlscan: 2.08st.  ​
 + ​Clear:​RC:​1(127.0.0.1):​. ​
 + ​Processed in 2.954303 secs); 10 Nov 2011 14:42:23 -0000
 +Received: from localhost (HELO mail.douglasqsantos.com.br) (douglas@douglasqsantos.com.br@127.0.0.1)
 +  by mail.douglasqsantos.com.br with AES256-SHA encrypted SMTP; 10 Nov 2011 12:42:10 -0200
 +From: Douglas <​douglas@douglasqsantos.com.br>​
 +To: Douglas <​douglas@douglasqsantos.com.br>​
 +Subject: Teste de envio de Email
 +Message-ID: <​1320936140101814826@mail>​
 +
 +Teste de Envio de Email por TLS
 +.
 +quit
 ++OK Bye-bye.
 +</​sxh>​
 +
 +Agora vamos efetuar um teste com Imap 
 +<sxh bash>
 +
 +telnet localhost 143
 +Trying 127.0.0.1...
 +Connected to localhost.
 +Escape character is '​^]'​.
 +* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION] Courier-IMAP ready. Copyright 1998-2010 Double Precision, Inc.  See COPYING for distribution information.
 +a login douglas@douglasqsantos.com.br doug123
 +a OK LOGIN Ok.
 +a logout
 +* BYE Courier-IMAP server shutting down
 +a OK LOGOUT completed
 +Connection closed by foreign host.
 +</​sxh>​
 +
 +Agora vamos efetuar o teste de autenticação do imap com SSL 
 +<sxh bash>
 +
 +openssl s_client -connect localhost:​993 -quiet ​
 +depth=0 /​C=BR/​ST=PR/​L=Curitiba/​O=Courier Mail Server/​OU=Automatically-generated IMAP SSL key/​CN=mail.douglasqsantos.com.br/​emailAddress=postmaster@douglasqsantos.com.br
 +verify error:​num=18:​self signed certificate
 +verify return:1
 +depth=0 /​C=BR/​ST=PR/​L=Curitiba/​O=Courier Mail Server/​OU=Automatically-generated IMAP SSL key/​CN=mail.douglasqsantos.com.br/​emailAddress=postmaster@douglasqsantos.com.br
 +verify return:1
 +* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION] Courier-IMAP ready. Copyright 1998-2010 Double Precision, Inc.  See COPYING for distribution information.
 +a login douglas@douglasqsantos.com.br doug123
 +a OK LOGIN Ok.
 +a logout
 +* BYE Courier-IMAP server shutting down
 +a OK LOGOUT completed
 +</​sxh>​
 +
 +Agora vamos instalar o validrcptto,​ que vai efetuar a validação dos usuários que existem na base de dados. ​
 +
 +Vamos acertar o pacote ​
 +<sxh bash>
 +cd /downloads/
 +tar xvzf cdb-0.75.tar.gz
 +cd /​downloads/​cdb-0.75
 +sed -i '/int errno/​{s/​^/​\/​* /;s/$/ *\;​G;​s/​$/#​include <​errno.h>/;​}'​ error.h
 +</​sxh>​
 +
 +Agora vamos mandar compilar e instalar ele
 +<sxh bash>
 +
 +make
 +make setup check
 +</​sxh>​
 +
 +Vamos instalar as dependências ​
 +<sxh bash>
 +
 +cd /​downloads/​deb-packages
 +dh-make-perl --build --install --cpan '​CDB_File'​
 +dpkg -i /​downloads/​deb-packages/​libcdb-file-perl_0.97-1_amd64.deb
 +</​sxh>​
 +
 +
 +Vamos acertar os scripts agora 
 +<sxh bash>
 +
 +cp /​downloads/​scripts/​mkvalidrcptto /​usr/​local/​bin
 +chmod 755 /​usr/​local/​bin/​mkvalidrcptto
 +cd /​var/​qmail/​control/​
 +/​home/​vpopmail/​bin/​vadddomain mail.douglasqsantos.com.br SENHA_DOMINIO
 +mkvalidrcptto > validrcptto.txt
 +cdbmake-12 validrcptto.cdb validrcptto.tmp < validrcptto.txt
 +</​sxh>​
 +
 +
 +Vamos acertar um arquivo de configuração ​
 +<sxh bash>
 +
 +vim /​var/​qmail/​supervise/​qmail-smtpd/​run
 +[...]
 +#Descomente as seguintes linhas
 +VALIDRCPTTO_CDB="​$VQ/​control/​validrcptto.cdb"​
 +VALIDRCPTTO_LIMIT=10
 +VALIDRCPTTO_LOG=2
 +</​sxh>​
 +
 +Agora vamos efetuar o agendamento da atualização do validrcptto ​
 +<sxh bash>
 +
 +cp /​downloads/​scripts/​update-validrcptto /​etc/​cron.hourly/​
 +chmod +x /​etc/​cron.hourly/​update-validrcptto ​
 +</​sxh>​
 +
 +Agora vamos reiniciar o qmail 
 +<sxh bash>
 +
 +qmailctl restart ​
 +Restarting qmail:
 +* Stopping qmail-smtpdssl.
 +* Stopping qmail-smtpd.
 +* Sending qmail-send SIGTERM and restarting.
 +* Restarting qmail-smtpd.
 +* Restarting qmail-smtpdssl.
 +</​sxh>​
 +
 +
 +Agora vamos instalar um greylist ​
 +
 +Vamos fazer um acerto no arquivo de inicialização do smtpd do qmail 
 +<sxh bash>
 +
 +vim /​var/​qmail/​supervise/​qmail-smtpd/​run
 +[...]
 +GREYLIST="/​var/​qmail/​bin/​jgreylist"​
 +JGREYLIST_DIR="​$VQ/​jgreylist"​
 +</​sxh>​
 +
 +Agora copiar os arquivos e acertar as permissões ​
 +<sxh bash>
 +
 +cp /​downloads/​scripts/​jgreylist /​var/​qmail/​bin
 +cp /​downloads/​scripts/​jgreylist-clean /​usr/​local/​sbin
 +chown root:vchkpw /​var/​qmail/​bin/​jgreylist
 +chmod 0750 /​var/​qmail/​bin/​jgreylist
 +chown root:root /​usr/​local/​sbin/​jgreylist-clean
 +chmod 0755 /​usr/​local/​sbin/​jgreylist-clean
 +mkdir -m 0700 /​var/​qmail/​jgreylist
 +chown vpopmail:​vchkpw /​var/​qmail/​jgreylist
 +echo '/​usr/​local/​sbin/​jgreylist-clean 2>&1 > /​dev/​null'​ > /​etc/​cron.daily/​jgreylist-clean
 +</​sxh>​
 +
 +
 +Agora vamos dar uma melhorada na performace no greylist ​
 +<sxh bash>
 +
 +cd /​downloads/​scripts/​
 +mv /​downloads/​scripts/​jgreylist /​downloads/​scripts/​jgreylist.pl
 +make jgreylist
 +cp /​downloads/​scripts/​jgreylist /​var/​qmail/​bin
 +chown root:vchkpw /​var/​qmail/​bin/​jgreylist
 +chmod 0750 /​var/​qmail/​bin/​jgreylist
 +</​sxh>​
 +
 +Agora vamos reiniciar o qmail 
 +<sxh bash>
 +
 +qmailctl restart ​
 +</​sxh>​
 +
 +
 +Agora vamos efetuar a instalação do DKIM 
 +
 +Vamos instalar o dkim 
 +<sxh bash>
 +
 +aptitude install libdkim-dev -y
 +</​sxh>​
 +
 +Agora vamos acertar a instalação ​
 +<sxh bash>
 +
 +mv /​var/​qmail/​bin/​qmail-remote /​var/​qmail/​bin/​qmail-remote.orig
 +cp /​downloads/​scripts/​qmail-remote /​var/​qmail/​bin/​qmail-remote
 +chown root:qmail /​var/​qmail/​bin/​qmail-remote
 +chmod 0755 /​var/​qmail/​bin/​qmail-remote
 +mkdir -p /​var/​domainkeys
 +chown qmailr:​qmail /​var/​domainkeys
 +chmod 0700 /​var/​domainkeys
 +</​sxh>​
 +
 +Agora vamos gerar a nossa chave DKIM 
 +<sxh bash>
 +
 +chmod +x /​downloads/​scripts/​domainkey
 +/​downloads/​scripts/​domainkey douglasqsantos.com.br
 +Generating RSA private key, 1024 bit long modulus
 +.......++++++
 +.............++++++
 +e is 65537 (0x10001)
 +writing RSA key
 +-e 
 +TXT record for BIND:
 +default._domainkey.douglasqsantos.com.br. IN TXT "​v=DKIM1\;​ k=rsa\; t=y\; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBaXSImetqrG08MQSi/​u2vB4mdb6QeXu9VradQy/​VJlM3zztfuZk+vRKwZBHWP2Q63+QmJR5O9EBTBXyeCuQnE9U4sy3/​XQn+JKQ91/​q+6aIXIO19L5fzlWqjPH5VHWtvC9WO4jnKmnReAo440gg2cC7WChYxjZ7ix+T+6Vtph9QIDAQAB"​
 +</​sxh>​
 +
 +
 +Agora temos que pegar essa chave e inserir no bind e reiniciar ele
 +
 +Temos que inserir a seguinte linha no meu caso
 +<sxh bash>
 +
 +default._domainkey.douglasqsantos.com.br. IN TXT "​v=DKIM1\;​ k=rsa\; t=y\; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBaXSImetqrG08MQSi/​u2vB4mdb6QeXu9VradQy/​VJlM3zztfuZk+vRKwZBHWP2Q63+QmJR5O9EBTBXyeCuQnE9U4sy3/​XQn+JKQ91/​q+6aIXIO19L5fzlWqjPH5VHWtvC9WO4jnKmnReAo440gg2cC7WChYxjZ7ix+T+6Vtph9QIDAQAB"​
 +</​sxh>​
 +
 +Agora vamos consultar os registros TXT do nosso domínio ​
 +<sxh bash>
 +dig @127.0.0.1 default._domainkey.douglasqsantos.com.br. txt
 +
 +; <<>>​ DiG 9.7.3 <<>>​ @127.0.0.1 default._domainkey.douglasqsantos.com.br. txt
 +; (1 server found)
 +;; global options: +cmd
 +;; Got answer:
 +;; ->>​HEADER<<​- opcode: QUERY, status: NOERROR, id: 17902
 +;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
 +
 +;; QUESTION SECTION:
 +;​default._domainkey.douglasqsantos.com.br. IN TXT
 +
 +;; ANSWER SECTION:
 +default._domainkey.douglasqsantos.com.br. 86400 IN TXT "​v=DKIM1\;​ k=rsa\; t=y\; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDBaXSImetqrG08MQSi/​u2vB4mdb6QeXu9VradQy/​VJlM3zztfuZk+vRKwZBHWP2Q63+QmJR5O9EBTBXyeCuQnE9U4sy3/​XQn+JKQ91/​q+6aIXIO19L5fzlWqjPH5VHWtvC9WO4jnKmnReAo440gg2cC7WChYxjZ7ix+T+6Vtph9QIDAQAB"​
 +
 +;; AUTHORITY SECTION:
 +douglasqsantos.com.br. ​ 86400 IN  NS  ns1.douglasqsantos.com.br.
 +douglasqsantos.com.br. ​ 86400 IN  NS  douglasqsantos.com.br.
 +douglasqsantos.com.br. ​ 86400 IN  NS  ns2.douglasqsantos.com.br.
 +
 +;; ADDITIONAL SECTION:
 +ns1.douglasqsantos.com.br. ​ 86400 IN  A 10.0.0.25
 +ns2.douglasqsantos.com.br. ​ 86400 IN  A 10.0.0.25
 +douglasqsantos.com.br. ​ 86400 IN  A 10.0.0.25
 +
 +;; Query time: 0 msec
 +;; SERVER: 127.0.0.1#​53(127.0.0.1)
 +;; WHEN: Thu Nov 10 16:24:07 2011
 +;; MSG SIZE  rcvd: 402
 +</​sxh>​
 +
 +Agora vamos acertar o mrtg para o Qmail 
 +
 +Agora vamos instalar as dependências ​
 +<sxh bash>
 +
 +aptitude install mrtg zlibc libpng12-dev
 +</​sxh>​
 +
 +Agora vamos instalar o qmailmrtg ​
 +<sxh bash>
 +
 +cd /downloads/
 +tar -zxvf qmailmrtg7-4.2.tar.gz
 +cd /​downloads/​qmailmrtg7-4.2
 +make && make install ​
 +</​sxh>​
 +
 +Agora vamos acertar os scripts ​
 +<sxh bash>
 +cd /​usr/​local/​bin/​
 +wget -c http://​wiki.douglasqsantos.com.br/​Downloads/​mail/​courierstats
 +mv /​usr/​local/​bin/​courierstats /​usr/​local/​bin/​courierstats.pl
 +chmod +x /​usr/​local/​bin/​courierstats.pl
 +</​sxh>​
 +
 +Agora vamos acertar o courierstats ​
 +<sxh bash>
 +
 +mkdir -p /​var/​www/​mail/​mrtg
 +cd /​var/​www/​mail/​mrtg
 +wget -c http://​wiki.douglasqsantos.com.br/​Downloads/​scripts/​index.mrtg
 +sed -i "​s/​MRTGHOSTNAME/​`hostname`/"​ /​var/​www/​mail/​mrtg/​index.mrtg
 +mv /​var/​www/​mail/​mrtg/​index.mrtg /​var/​www/​mail/​mrtg/​index.html
 +</​sxh>​
 +
 +Agora vamos acertar o arquivo de configuração do mrtg 
 +<sxh bash>
 +cd /etc/
 +mv /​etc/​mrtg.cfg /​etc/​mrtg.cfg.orig
 +wget -c http://​wiki.douglasqsantos.com.br/​Downloads/​scripts/​qmail.mrtg.cfg
 +sed -i "​s/​MRTGHOSTNAME/​`hostname`/"​ /​etc/​qmail.mrtg.cfg
 +mv /​etc/​qmail.mrtg.cfg /​etc/​mrtg.cfg ​
 +</​sxh>​
 +
 +Agora vamos acertar o logrotate ​
 +<sxh bash>
 +
 +vim /​etc/​logrotate.d/​rsyslog
 +/​var/​log/​mail.info
 +/​var/​log/​mail.warn
 +/​var/​log/​mail.err
 +/​var/​log/​mail.log
 +/​var/​log/​daemon.log
 +/​var/​log/​kern.log
 +/​var/​log/​auth.log
 +/​var/​log/​user.log
 +/​var/​log/​lpr.log
 +/​var/​log/​cron.log
 +/​var/​log/​debug
 +/​var/​log/​messages
 +{
 +  rotate 30
 +  daily
 +  missingok
 +  notifempty
 +  compress
 +  delaycompress
 +  sharedscripts
 +  postrotate
 +    invoke-rc.d rsyslog reload > /dev/null
 +  endscript
 +}
 +</​sxh>​
 +
 +
 +Agora vamos instalar o roundcubemail ​
 +<sxh bash>
 +cd /downloads/
 +tar zxvfp roundcubemail-0.6.tar.gz
 +chown -R root:root /​downloads/​roundcubemail-0.6
 +mv /​downloads/​roundcubemail-0.6 /​var/​www/​mail/​
 +ln -s /​var/​www/​mail/​roundcubemail-0.6/​ /​var/​www/​mail/​webmail
 +ln -s /​var/​www/​mail/​webmail/​logs /​var/​log/​webmail
 +chmod 777 /​var/​www/​mail/​webmail/​logs/​
 +chmod 777 /​var/​www/​mail/​webmail/​temp/​
 +</​sxh>​
 +
 +Agora vamos preparar a base de dados para o webmail ​
 +<sxh sql>
 +
 +mysql -u root -p
 +CREATE DATABASE roundcubemail;​
 +GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost IDENTIFIED BY '​ROUNDCUBEMAILPASSWORD';​
 +quit;
 +</​sxh>​
 +
 +Testando a conexão do nosso novo usuário ​
 +<sxh sql>
 +
 +mysql -uroundcube -pROUNDCUBEMAILPASSWORD
 +Welcome to the MySQL monitor. ​ Commands end with ; or \g.
 +Your MySQL connection id is 311
 +Server version: 5.1.49-3 (Debian)
 +
 +Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
 +This software comes with ABSOLUTELY NO WARRANTY. This is free software,
 +and you are welcome to modify and redistribute it under the GPL v2 license
 +
 +Type '​help;'​ or '​\h'​ for help. Type '​\c'​ to clear the current input statement.
 +
 +mysql> quit
 +Bye
 +</​sxh>​
 +
 +
 +Vamos acertar a configuração do webmail ​
 +<sxh bash>
 +
 +cd /​var/​www/​mail/​webmail
 +mysql -uroundcube -pROUNDCUBEMAILPASSWORD roundcubemail < SQL/​mysql.initial.sql
 +cp /​var/​www/​mail/​webmail/​config/​db.inc.php.dist /​var/​www/​mail/​webmail/​config/​db.inc.php
 +cp /​var/​www/​mail/​webmail/​config/​main.inc.php.dist /​var/​www/​mail/​webmail/​config/​main.inc.php
 +</​sxh>​
 +
 +Vamos fazer alguns acertos no arquivo de configuração ​
 +<sxh php>
 +vim /​var/​www/​mail/​webmail/​config/​main.inc.php
 +$rcmail_config['​enable_installer'​] = true;
 +$rcmail_config['​smtp_server'​] = '​tls:​localhost';​
 +$rcmail_config['​smtp_port'​] = 25;
 +$rcmail_config['​default_host'​] = '​ssl:​localhost';​
 +$rcmail_config['​default_port'​] = 993;
 +$rcmail_config['​drafts_mbox'​] = '​INBOX.Drafts';​
 +$rcmail_config['​junk_mbox'​] = '​INBOX.Junk';​
 +$rcmail_config['​sent_mbox'​] = '​INBOX.Sent';​
 +$rcmail_config['​trash_mbox'​] = '​INBOX.Trash';​
 +$rcmail_config['​default_imap_folders'​] = array('​INBOX',​ '​INBOX.Drafts',​ '​INBOX.Sent',​ '​INBOX.Junk',​ '​INBOX.Trash'​);​
 +$rcmail_config['​create_default_folders'​] = true';
 +$rcmail_config['​language'​] = pt_BR;
 +</​sxh>​
 +
 +Agora vamos configurar a conexão com o banco de dados 
 +<sxh php>
 +vim /​var/​www/​mail/​webmail/​config/​db.inc.php
 +$rcmail_config['​db_dsnw'​] = '​mysql:​roundcube:​ROUNDCUBEMAILPASSWORD@localhost/​roundcubemail'; ​
 +</​sxh>​
 +
 +Agora vamos reiniciar o apache ​
 +<sxh bash>
 +
 +/​etc/​init.d/​apache2 restart
 +</​sxh>​
 +
 +Agora vamos remover os arquivos que não são mais necessários ​
 +<sxh bash>
 +
 +cd /​var/​www/​mail/​webmail
 +rm -rf installer/ CHANGELOG INSTALL LICENSE README UPGRADING
 +</​sxh>​
 +
 +O seu webmail está em http://​mailadmin.douglasqsantos.com.br/​webmail ​
 +
 +====== Referências ======
 +
 +  - http://​www.lifewithqmail.com
 +  - http://​www.lifewithqmail.com/​lwq.html#​configuration
 +  - http://​qmail.jms1.net/​patches/​validrcptto.cdb.shtml
 +  - http://​www.x86linux.org/​wiki/​index.php/​Valid_RCPT_TO_for_qmail
 +  - http://​www.dkim.org
 +  - http://​qmailrocks.thibs.com/​