Usei como base o seguinte tutorial:
http://www.howtoforg...il-ubuntu-10.10
O problema:
Não consigo receber emails através do postfix para usuários virtuais, mas consigo enviar! Quando tento logar através do pop3/imap occorem erros.
Bom abaixo seguem os testes de conexões, arquivos de log, aquivos de configuração, e apresentação dos erros. Peço desculpas pois o post vai ficar um tanto quanto extenso.
- conexão postfix:
user@DNSERVER:/etc/courier$ telnet localhost 25 Trying 127.0.0.1... Connected to DNSERVER. Escape character is '^]'. 220 networkclub.com.br ESMTP Postfix (Debian/GNU) ehlo localhost 250-networkclub.com.br 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-STARTTLS 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN quit 221 2.0.0 Bye Connection closed by foreign host.
- envio email postfix:
telnet: envio de email user@DNSERVER:/etc/courier$ telnet localhost 25 Trying 127.0.0.1... Connected to DNSERVER. Escape character is '^]'. 220 networkclub.com.br ESMTP Postfix (Debian/GNU) Mail from: cleber 250 2.1.0 Ok RCPT to: cleber@othermails.com 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF> Está enviando! . 250 2.0.0 Ok: queued as AE17D6C2097 quit 221 2.0.0 Bye Connection closed by foreign host. OBS: quando este email é recebido o remetente aparece clebe@networkclub.com.br
- conexão pop3:
user@DNSERVER:/etc/courier$ telnet localhost 110 Trying 127.0.0.1... Connected to DNSERVER. Escape character is '^]'. +OK Hello there. quit +OK Better luck next time. Connection closed by foreign host.
- conexão imap:
user@DNSERVER:/etc/courier$ telnet localhost 143 Trying 127.0.0.1... Connected to DNSERVER. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2010 Double Precision, Inc. See COPYING for distribution information.
- conexões servidores: netstat -tap
Proto Recv-Q Send-Q Endereço Local Endereço Remoto Estado PID/Program name tcp 0 0 DNSERVER:mysql *:* OUÇA - tcp 0 0 *:sunrpc *:* OUÇA - tcp 0 0 DNSERVER.local:domain *:* OUÇA - tcp 0 0 DNSERVER.local:domain *:* OUÇA - tcp 0 0 DNSERVER:domain *:* OUÇA - tcp 0 0 DNSERVER:ipp *:* OUÇA - tcp 0 0 *:44952 *:* OUÇA - tcp 0 0 *:smtp *:* OUÇA - tcp 0 0 DNSERVER:953 *:* OUÇA - tcp 0 0 DNSERVER:10024 *:* OUÇA - tcp 0 0 DNSERVER:10025 *:* OUÇA - tcp 0 0 DNSERVER:44941 DNSERVER:mysql ESTABELECIDA - tcp 0 0 DNSERVER:44962 DNSERVER:mysql ESTABELECIDA - tcp 0 0 DNSERVER:mysql DNSERVER:44962 ESTABELECIDA - tcp 0 0 DNSERVER:mysql DNSERVER:44941 ESTABELECIDA - tcp6 0 0 [::]:pop3 [::]:* OUÇA - tcp6 0 0 [::]:imap2 [::]:* OUÇA - tcp6 0 0 [::]:www [::]:* OUÇA - tcp6 0 0 [::]:domain [::]:* OUÇA - tcp6 0 0 [::]:ftp [::]:* OUÇA - tcp6 0 0 ip6-localhost:ipp [::]:* OUÇA - tcp6 0 0 ip6-localhost:953 [::]:* OUÇA - tcp6 0 0 [::]:imaps [::]:* OUÇA - tcp6 0 0 [::]:pop3s [::]:* OUÇA - tcp6 0 0 DNSERVER:imap2 DNSERVER:43198 TIME_WAIT -
------------------------------------------------------------------------------------
| *************************************ERROS******************* |
------------------------------------------------------------------------------------
- logar imap:
user@DNSERVER:/$ telnet localhost 143 Trying 127.0.0.1... Connected to DNSERVER. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2010 Double Precision, Inc. See COPYING for distribution information. 1 login cleber@networkclub.com.br xxxxxxxxxxx * BYE [ALERT] Fatal error: No such file or directory: No such file or directory Connection closed by foreign host.
- logar pop3:
user@DNSERVER:/$ telnet localhost 110 Trying 127.0.0.1... Connected to DNSERVER. Escape character is '^]'. +OK Hello there. user cleber@networkclub.com.br +OK Password required. pass xxxxxxxxxxxxx -ERR chdir networkclub.com.br/cleber/ failed Connection closed by foreign host.
Erro ao tentar logar através do squirrelmail (web)
ERROR: Connection dropped by IMAP server.
------------------------------------------------------------------------------------
| *************************************LOGS******************** |
------------------------------------------------------------------------------------
- user@DNSERVER:/$ tail /var/log/mail.log
Nov 3 13:30:45 DNSERVER pop3d: LOGOUT, ip=[::ffff:127.0.0.1] Nov 3 13:30:45 DNSERVER pop3d: Disconnected, ip=[::ffff:127.0.0.1] Nov 3 13:32:02 DNSERVER imapd: Connection, ip=[::ffff:127.0.0.1] Nov 3 13:32:18 DNSERVER imapd: (null): TOO MANY CONSECUTIVE PROTOCOL VIOLATIONS Nov 3 13:32:20 DNSERVER imapd: Connection, ip=[::ffff:127.0.0.1] Nov 3 13:36:47 DNSERVER imapd: Connection, ip=[::ffff:127.0.0.1] Nov 3 13:37:06 DNSERVER imapd: chdir networkclub.com.br/cleber/: No such file or directory Nov 3 13:37:06 DNSERVER imapd: cleber@networkclub.com.br: No such file or directory Nov 3 13:39:04 DNSERVER pop3d: Connection, ip=[::ffff:127.0.0.1] Nov 3 13:39:18 DNSERVER pop3d: chdir networkclub.com.br/cleber/: No such file or directory
user@DNSERVER:/$ tail /var/log/mail.log
Nov 3 13:30:45 DNSERVER pop3d: LOGOUT, ip=[::ffff:127.0.0.1] Nov 3 13:30:45 DNSERVER pop3d: Disconnected, ip=[::ffff:127.0.0.1] Nov 3 13:32:02 DNSERVER imapd: Connection, ip=[::ffff:127.0.0.1] Nov 3 13:32:18 DNSERVER imapd: (null): TOO MANY CONSECUTIVE PROTOCOL VIOLATIONS Nov 3 13:32:20 DNSERVER imapd: Connection, ip=[::ffff:127.0.0.1] Nov 3 13:36:47 DNSERVER imapd: Connection, ip=[::ffff:127.0.0.1] Nov 3 13:37:06 DNSERVER imapd: chdir networkclub.com.br/cleber/: No such file or directory Nov 3 13:37:06 DNSERVER imapd: cleber@networkclub.com.br: No such file or directory Nov 3 13:39:04 DNSERVER pop3d: Connection, ip=[::ffff:127.0.0.1] Nov 3 13:39:18 DNSERVER pop3d: chdir networkclub.com.br/cleber/: No such file or directory
- MENSAGEM DE RETORNO DE UM EMAIL ENVIADO PARA cleber@networkclub.com.br
Mail Delivery System MAILER-DAEMON@networkclub.com.br para mim mostrar detalhes 12:25 (1 hora atrás) This is the mail system at host networkclub.com.br. I'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below. For further assistance, please send mail to postmaster. If you do so, please include this problem report. You can delete your own text from the attached returned message. The mail system <networkclub.com.br/cleber/@networkclub.com.br> (expanded from <cleber@networkclub.com.br>): unknown user: "networkclub.com.br/cleber/" Final-Recipient: rfc822; networkclub.com.br/cleber/@networkclub.com.br Original-Recipient: rfc822;cleber@networkclub.com.br Action: failed Status: 5.1.1 Diagnostic-Code: X-Postfix; unknown user: "networkclub.com.br/cleber/"
------------------------------------------------------------------------------------
| *********************************Arquivos de configuração*************** |
------------------------------------------------------------------------------------
Seguindo as instruções do tutorial eu configurei os seis arquivos para utilização de usuários virtuais no postfix:
/etc/postfix/mysql-virtual_domains.cf
/etc/postfix/mysql-virtual_forwardings.cf
/etc/postfix/mysql-virtual_mailboxes.cf
/etc/postfix/mysql-virtual_email2email.cf
/etc/postfix/mysql-virtual_transports.cf
/etc/postfix/mysql-virtual_mailbox_limit_maps.cf
Crei o diretório para alocação das caixas de entradas virtuais:
/home/vmail.
Arquivos de configuração:
/etc/postfix/main.cf
# See /usr/share/postfix/main.cf.dist for a commented, more complete version # Debian specific: Specifying a file name will cause the first # line of that file to be used as the name. The Debian default # is /etc/mailname. #myorigin = /etc/mailname smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h readme_directory = /usr/share/doc/postfix # TLS parameters smtpd_tls_cert_file = /etc/postfix/smtpd.cert smtpd_tls_key_file = /etc/postfix/smtpd.key smtpd_use_tls = yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for # information on enabling SSL in the smtp client. myhostname = networkclub.com.br mydomain = networkclub.com.br alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydestination = localhost, localhost.localdomain, networkclub.com.br relayhost = mynetworks = 127.0.0.0/8 mailbox_command = procmail -a "$EXTENSION" mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all html_directory = /usr/share/doc/postfix/html virtual_alias_domains = virtual_alias_maps = proxy:mysql:/etc/postfix/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql-virtual_email2email.cf virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql-virtual_domains.cf virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailboxes.cf virtual_mailbox_base = /home/vmail virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 smtpd_sasl_auth_enable = yes broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination transport_maps = proxy:mysql:/etc/postfix/mysql-virtual_transports.cf virtual_create_maildirsize = yes virtual_maildir_extended = yes virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql-virtual_mailbox_limit_maps.cf virtual_mailbox_limit_override = yes virtual_maildir_limit_message = "The user you are trying to reach is over quota." virtual_overquota_bounce = yes proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps content_filter = amavis:[127.0.0.1]:10024 receive_override_options = no_address_mappings smtpd_tls_security_level = may relay_domains = mysql:/etc/postfix/mysql-virtual_relaydomains.cf relay_recipient_maps = mysql:/etc/postfix/mysql-virtual_relayrecipientmaps.cf smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf smtpd_client_restrictions = check_client_access mysql:/etc/postfix/mysql-virtual_client.cf maildrop_destination_concurrency_limit = 1 maildrop_destination_recipient_limit = 1 virtual_transport = maildrop header_checks = regexp:/etc/postfix/header_checks mime_header_checks = regexp:/etc/postfix/mime_header_checks nested_header_checks = regexp:/etc/postfix/nested_header_checks body_checks = regexp:/etc/postfix/body_checks
/etc/postfix/master.cf
# # Postfix master process configuration file. For details on the format # of the file, see the master(5) manual page (command: "man 5 master"). # # Do not forget to execute "postfix reload" after editing this file. # # ========================================================================== # service type private unpriv chroot wakeup maxproc command + args # (yes) (yes) (yes) (never) (100) # ========================================================================== smtp inet n - - - - smtpd #submission inet n - - - - smtpd # -o smtpd_tls_security_level=encrypt # -o smtpd_sasl_auth_enable=yes # -o smtpd_client_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING #smtps inet n - - - - smtpd # -o smtpd_tls_wrappermode=yes # -o smtpd_sasl_auth_enable=yes # -o smtpd_client_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING #628 inet n - - - - qmqpd pickup fifo n - - 60 1 pickup cleanup unix n - - - 0 cleanup qmgr fifo n - n 300 1 qmgr #qmgr fifo n - - 300 1 oqmgr tlsmgr unix - - - 1000? 1 tlsmgr rewrite unix - - - - - trivial-rewrite bounce unix - - - - 0 bounce defer unix - - - - 0 bounce trace unix - - - - 0 bounce verify unix - - - - 1 verify flush unix n - - 1000? 0 flush proxymap unix - - n - - proxymap proxywrite unix - - n - 1 proxymap smtp unix - - - - - smtp # When relaying mail as backup MX, disable fallback_relay to avoid MX loops relay unix - - - - - smtp -o smtp_fallback_relay= # -o smtp_helo_timeout=5 -o smtp_connect_timeout=5 showq unix n - - - - showq error unix - - - - - error retry unix - - - - - error discard unix - - - - - discard local unix - n n - - local virtual unix - n n - - virtual lmtp unix - - - - - lmtp anvil unix - - - - 1 anvil scache unix - - - - 1 scache # # ==================================================================== # Interfaces to non-Postfix software. Be sure to examine the manual # pages of the non-Postfix software to find out what options it wants. # # Many of the following services use the Postfix pipe(8) delivery # agent. See the pipe(8) man page for information about ${recipient} # and other message envelope options. # ==================================================================== # # maildrop. See the Postfix MAILDROP_README file for details. # Also specify in main.cf: maildrop_destination_recipient_limit=1 # maildrop unix - n n - - pipe flags=DRhu user=vmail argv=/usr/bin/maildrop -d vmail ${extension} ${recipient} ${user} ${nexthop} ${sender} # # ==================================================================== # # Recent Cyrus versions can use the existing "lmtp" master.cf entry. # # Specify in cyrus.conf: # lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4 # # Specify in main.cf one or more of the following: # mailbox_transport = lmtp:inet:localhost # virtual_transport = lmtp:inet:localhost # # ==================================================================== # # Cyrus 2.1.5 (Amos Gouaux) # Also specify in main.cf: cyrus_destination_recipient_limit=1 # #cyrus unix - n n - - pipe # user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user} # # ==================================================================== # Old example of delivery via Cyrus. # #old-cyrus unix - n n - - pipe # flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user} # # ==================================================================== # # See the Postfix UUCP_README file for configuration details. # uucp unix - n n - - pipe flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient) # # Other external delivery methods. # ifmail unix - n n - - pipe flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient) bsmtp unix - n n - - pipe flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient scalemail-backend unix - n n - 2 pipe flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension} mailman unix - n n - - pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user} #======================================================================= #amavis amavis unix - - - - 2 smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes 127.0.0.1:10025 inet n - - - - smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -o smtpd_client_restrictions= -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 -o strict_rfc821_envelopes=yes -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks -o smtpd_bind_address=127.0.0.1
/etc/pam.d/smtp
auth required pam_mysql.so user=mail_admin passwd=xxxxxxxxxx host=127.0.0.1 db=mail table=users usercolumn=email passwdcolumn=password crypt=1 account sufficient pam_mysql.so user=mail_admin passwd=xxxxxxxxxx host=127.0.0.1 db=mail table=users usercolumn=email passwdcolumn=password crypt=1
/etc/postfix/sasl/smtpd.conf
pwcheck_method: saslauthd mech_list: plain login allow_plaintext: true auxprop_plugin: mysql sql_hostnames: 127.0.0.1 sql_user: mail_admin sql_passwd: xxxxxxxxxxxx sql_database: mail sql_select: select password from users where email = '%u'
/etc/courier/authdaemonrc
... ##NAME: authmodulelist:2 # # The authentication modules that are linked into authdaemond. The # default list is installed. You may selectively disable modules simply # by removing them from the following list. The available modules you # can use are: authuserdb authpam authpgsql authldap authmysql authcustom authpipe authmodulelist="authmysql" ...
/etc/courier/authmysqlrc
MYSQL_SERVER localhost MYSQL_USERNAME mail_admin MYSQL_PASSWORD xxxxxxxxxxxxxxx MYSQL_PORT 0 MYSQL_DATABASE mail MYSQL_USER_TABLE users MYSQL_CRYPT_PWFIELD password #MYSQL_CLEAR_PWFIELD password MYSQL_UID_FIELD 5000 MYSQL_GID_FIELD 5000 MYSQL_LOGIN_FIELD email MYSQL_HOME_FIELD "/home/vmail" MYSQL_MAILDIR_FIELD CONCAT(SUBSTRING_INDEX(email,'@',-1),'/',SUBSTRING_INDEX(email,'@',1),'/') #MYSQL_NAME_FIELD MYSQL_QUOTA_FIELD quota
/etc/courier/imapd.cnf
RANDFILE = /usr/lib/courier/imapd.rand [ req ] default_bits = 1024 encrypt_key = yes distinguished_name = req_dn x509_extensions = cert_type prompt = no [ req_dn ] C=BR ST=RS L=Porto Alegre O=Courier Mail Server OU=Automatically-generated IMAP SSL key CN=networkclub.com.br emailAddress = postmaster@networkclub.com.br [ cert_type ] nsCertType = server
/etc/courier/pop3d.cnf
RANDFILE = /usr/lib/courier/pop3d.rand [ req ] default_bits = 1024 encrypt_key = yes distinguished_name = req_dn x509_extensions = cert_type prompt = no [ req_dn ] C=BR ST=RS L=Porto Alegre O=Courier Mail Server OU=Automatically-generated POP3 SSL key CN=networkclub.com.br emailAddress=postmaster@networkclub.com.br [ cert_type ] nsCertType = server