docker-mailserver / docker-mailserver

Production-ready fullstack but simple mail server (SMTP, IMAP, LDAP, Antispam, Antivirus, etc.) running inside a container.
https://docker-mailserver.github.io/docker-mailserver/latest/
MIT License
14.57k stars 1.82k forks source link

unable to receive emails #1294

Closed digounet closed 5 years ago

digounet commented 5 years ago

Hi, i've installed this container and successful send email messages, but when I tried to receive an email I have an error:

mail | Oct 15 16:06:23 mail policyd-spf[1483]: prepend Received-SPF: Permerror (mailfrom) identity=mailfrom; client-ip=209.85.XXX.XXX; helo=mail-qk1-f181.google.com; envelope-from=palves@xxxxxx.com.br; receiver=<UNKNOWN> mail | Oct 15 16:06:23 mail postfix/smtpd[1226]: NOQUEUE: reject: RCPT from mail-qk1-f181.google.com[209.85.222.181]: 550 5.1.1 <pablo@meudominio.com.br>: Recipient address rejected: User unknown in local recipient table; from=<palves@xxxxxx.com.br> to=<pablo@meudominio.com.br> proto=ESMTP helo=<mail-qk1-f181.google.com>

erik-wramner commented 5 years ago

It looks like you haven't defined pablo@meudominio.com.br as a user, but it is hard to tell. The template is not all bad - it is impossible to help you without more details about your configuration, what you have done and possibly more logs.

pengsamuel commented 5 years ago

I have a same problem. Is this a new bug in latest version?

digounet commented 5 years ago

I’ve not tried but this problem is described in postfix official documentation: http://www.postfix.org/LOCAL_RECIPIENT_README.html

erik-wramner commented 5 years ago

@pengsamuel and @digounet it could be a bug in the latest version, but I'm a bit skeptical as there have been few changes and this should hit all users (me included) unless you are doing something special. To fix the bug if there is one or to solve your problem if it is a matter of your configuration we need to know the details.

Please share the commands you used when you installed and your configuration options and the rest of the logs when this happens. In particular we need to know details for the involved users. Is there a pablo@meudominio.com.br in the accounts file, for example.

digounet commented 5 years ago

Hello,

steps to reproduce (my_domain is not the real domain):

  1. started a new computer instance

  2. created A record pointing to instance IP

  3. created MX record pointing to instance IP

  4. changed computer hostname no my_domain in /etc/hostname and also changed the /etc/hosts files

  5. added a new user pablo@my_domain

  6. install container `docker pull tvial/docker-mailserver:latest

curl -o setup.sh https://raw.githubusercontent.com/tomav/docker-mailserver/master/setup.sh; chmod a+x ./setup.sh curl -o docker-compose.yml https://raw.githubusercontent.com/tomav/docker-mailserver/master/docker-compose.yml.dist curl -o .env https://raw.githubusercontent.com/tomav/docker-mailserver/master/.env.dist`

  1. changed hostname and domain in .env to my_domain

  2. copied env-mailserver file from https://raw.githubusercontent.com/tomav/docker-mailserver/master/env-mailserver.dist

  3. changes in file: OVERRIDE_HOSTNAME=my_domain POSTMASTER_ADDRESS=pablo@my_domain SPOOF_PROTECTION=1 ENABLE_SPAMASSASSIN=1

  4. added user with ./setup.sh email add pablo@my_domain

  5. generated dkim with ./setup.sh config dkim

  6. added key to my dns provider

  7. started container with docker-compose up mail

Log pablo@my_domain:~/containers/mailcontainer$ docker-compose up mail Starting mail ... done Attaching to mail mail | 2019-10-16 12:45:16,887 CRIT Supervisor running as root (no user in config file) mail | 2019-10-16 12:45:16,891 INFO Included extra file "/etc/supervisor/conf.d/saslauth.conf" during parsing mail | 2019-10-16 12:45:16,894 INFO Included extra file "/etc/supervisor/conf.d/supervisor-app.conf" during parsing mail | 2019-10-16 12:45:16,957 INFO RPC interface 'supervisor' initialized mail | 2019-10-16 12:45:16,961 CRIT Server 'unix_http_server' running without any HTTP authentication checking mail | 2019-10-16 12:45:16,964 INFO supervisord started with pid 1 mail | 2019-10-16 12:45:17,967 INFO spawned: 'mailserver' with pid 8 mail | mail | 2019-10-16 12:45:18,345 INFO success: mailserver entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) mail | # mail | # mail | # docker-mailserver mail | # mail | # mail | mail | Initializing setup mail | Checking configuration mail | Configuring mail server mail | * Clamav is disabled. You can enable it with 'ENABLE_CLAMAV=1' mail | /tmp/docker-mailserver / mail | / mail | Starting Misc mail | Starting mail server mail | 2019-10-16 12:45:23,092 INFO spawned: 'cron' with pid 121 mail | 2019-10-16 12:45:23,093 INFO success: cron entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) mail | cron: started mail | 2019-10-16 12:45:23,770 INFO spawned: 'rsyslog' with pid 123 mail | 2019-10-16 12:45:23,771 INFO success: rsyslog entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) mail | rsyslog: started mail | 2019-10-16 12:45:24,493 INFO spawned: 'dovecot' with pid 127 mail | 2019-10-16 12:45:24,494 INFO success: dovecot entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) mail | dovecot: started mail | 2019-10-16 12:45:25,455 INFO spawned: 'opendkim' with pid 134 mail | 2019-10-16 12:45:25,456 INFO success: opendkim entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) mail | opendkim: started mail | 2019-10-16 12:45:26,164 INFO spawned: 'opendmarc' with pid 142 mail | 2019-10-16 12:45:26,164 INFO success: opendmarc entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) mail | opendmarc: started mail | 2019-10-16 12:45:26,864 INFO spawned: 'postfix' with pid 149 mail | 2019-10-16 12:45:26,865 INFO success: postfix entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) mail | postfix: started mail | 2019-10-16 12:45:27,961 INFO spawned: 'changedetector' with pid 219 mail | 2019-10-16 12:45:27,962 INFO success: changedetector entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) mail | changedetector: started mail | 2019-10-16 12:45:28,978 INFO spawned: 'amavis' with pid 357 mail | 2019-10-16 12:45:28,978 INFO success: amavis entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) mail | amavis: started mail | mail | # mail | # my_domain.com.br is up and running mail | # mail | mail | Oct 16 12:45:32 my_domain amavis[357]: starting. /usr/sbin/amavisd-new at my_domain.com.br amavisd-new-2.10.1 (20141025), Unicode aware mail | Oct 16 12:45:33 my_domain postfix/master[900]: daemon started -- version 3.1.12, configuration /etc/postfix mail | Oct 16 12:45:33 my_domain amavis[357]: Net::Server: Group Not Defined. Defaulting to EGID '111 111' mail | Oct 16 12:45:33 my_domain amavis[357]: Net::Server: User Not Defined. Defaulting to EUID '109' mail | Oct 16 12:45:33 my_domain amavis[357]: Module Amavis::Conf 2.404 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Archive::Zip 1.59 mail | Oct 16 12:45:33 my_domain amavis[357]: Module BerkeleyDB 0.55 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Compress::Raw::Zlib 2.069 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Compress::Zlib 2.069001 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Crypt::OpenSSL::RSA 0.28 mail | Oct 16 12:45:33 my_domain amavis[357]: Module DB_File 1.835 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Digest::MD5 2.54 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Digest::SHA 5.95_01 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Encode 2.80_01 mail | Oct 16 12:45:33 my_domain amavis[357]: Module File::Temp 0.2304 mail | Oct 16 12:45:33 my_domain amavis[357]: Module IO::Socket::INET6 2.72 mail | Oct 16 12:45:33 my_domain amavis[357]: Module IO::Socket::IP 0.37 mail | Oct 16 12:45:33 my_domain amavis[357]: Module MIME::Entity 5.508 mail | Oct 16 12:45:33 my_domain amavis[357]: Module MIME::Parser 5.508 mail | Oct 16 12:45:33 my_domain amavis[357]: Module MIME::Tools 5.508 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Mail::DKIM::Verifier 0.4 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Mail::Header 2.18 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Mail::Internet 2.18 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Mail::SPF v2.009 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Mail::SpamAssassin 3.004002 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Net::DNS 1.07 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Net::LibIDN 0.12 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Net::Server 2.008 mail | Oct 16 12:45:33 my_domain amavis[357]: Module NetAddr::IP 4.079 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Razor2::Client::Version 2.84 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Scalar::Util 1.4202 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Socket 2.020_03 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Socket6 0.27 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Time::HiRes 1.9733 mail | Oct 16 12:45:33 my_domain amavis[357]: Module URI 1.71 mail | Oct 16 12:45:33 my_domain amavis[357]: Module Unix::Syslog 1.1 mail | Oct 16 12:45:33 my_domain amavis[357]: Amavis::ZMQ code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: Amavis::DB code loaded mail | Oct 16 12:45:33 my_domain amavis[357]: SQL base code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: SQL::Log code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: SQL::Quarantine NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: Lookup::SQL code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: Lookup::LDAP code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: AM.PDP-in proto code loaded mail | Oct 16 12:45:33 my_domain amavis[357]: SMTP-in proto code loaded mail | Oct 16 12:45:33 my_domain amavis[357]: Courier proto code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: SMTP-out proto code loaded mail | Oct 16 12:45:33 my_domain amavis[357]: Pipe-out proto code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: BSMTP-out proto code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: Local-out proto code loaded mail | Oct 16 12:45:33 my_domain amavis[357]: OS_Fingerprint code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: ANTI-VIRUS code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: ANTI-SPAM code loaded mail | Oct 16 12:45:33 my_domain amavis[357]: ANTI-SPAM-EXT code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: ANTI-SPAM-C code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: ANTI-SPAM-SA code loaded mail | Oct 16 12:45:33 my_domain amavis[357]: Unpackers code loaded mail | Oct 16 12:45:33 my_domain amavis[357]: DKIM code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: Tools code NOT loaded mail | Oct 16 12:45:33 my_domain amavis[357]: Found $file at /usr/bin/file mail | Oct 16 12:45:33 my_domain amavis[357]: No $altermime, not using it mail | Oct 16 12:45:33 my_domain amavis[357]: Internal decoder for .mail mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .Z at /bin/uncompress mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .gz at /bin/gzip -d mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .bz2 at /bin/bzip2 -d mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .xz at /usr/bin/xz -dc mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .lzma at /usr/bin/xz -dc --format=lzma mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .lrz at /usr/bin/lrzip -q -k -d -o - mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .lzo at /usr/bin/lzop -d mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .lz4 at /usr/bin/lz4c -d mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .rpm at /usr/bin/rpm2cpio mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .cpio at /bin/pax mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .tar at /bin/pax mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .deb at /usr/bin/ar mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .rar at /usr/bin/unrar-free mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .arj at /usr/bin/arj mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .arc at /usr/bin/nomarch mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .zoo at /usr/bin/zoo mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .doc at /usr/bin/ripole mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .cab at /usr/bin/cabextract mail | Oct 16 12:45:33 my_domain amavis[357]: Internal decoder for .tnef mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .zip at /usr/bin/7za mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .kmz at /usr/bin/7za mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .7z at /usr/bin/7zr mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .jar at /usr/bin/7z mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .swf at /usr/bin/7z mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .lha at /usr/bin/7z mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .iso at /usr/bin/7z mail | Oct 16 12:45:33 my_domain amavis[357]: Found decoder for .exe at /usr/bin/unrar-free; /usr/bin/arj mail | Oct 16 12:45:33 my_domain amavis[357]: No decoder for .F mail | Oct 16 12:45:33 my_domain amavis[357]: Deleting db files in /var/lib/amavis/db mail | Oct 16 12:45:33 my_domain amavis[357]: Creating db in /var/lib/amavis/db/; BerkeleyDB 0.55, libdb 5.3 mail | Oct 16 12:46:16 my_domain postfix/postscreen[1040]: cache btree:/var/lib/postfix/postscreen_cache full cleanup: retained=0 dropped=0 entries mail | Oct 16 12:46:16 my_domain postfix/postscreen[1040]: CONNECT from [209.85.222.180]:36127 to [172.18.0.2]:25 mail | Oct 16 12:46:18 my_domain postfix/dnsblog[1045]: addr 209.85.222.180 listed by domain list.dnswl.org as 127.0.5.0 mail | Oct 16 12:46:20 my_domain postfix/dnsblog[1047]: addr 209.85.222.180 listed by domain dnsbl.sorbs.net as 127.0.0.6 mail | Oct 16 12:46:20 my_domain postfix/postscreen[1040]: PASS NEW [209.85.222.180]:36127 mail | Oct 16 12:46:20 my_domain postfix/smtpd[1063]: warning: cannot load 1024-bit DH parameters from file /etc/postfix/dhparams.pem -- using compiled-in defaults mail | Oct 16 12:46:20 my_domain postfix/smtpd[1063]: warning: TLS library problem: error:0906D06C:PEM routines:PEM_read_bio:no start line:../crypto/pem/pem_lib.c:686:Expecting: DH PARAMETERS: mail | Oct 16 12:46:21 my_domain postfix/smtpd[1063]: connect from mail-qk1-f180.google.com[209.85.222.180] mail | Oct 16 12:46:22 my_domain postfix/smtpd[1063]: Anonymous TLS connection established from mail-qk1-f180.google.com[209.85.222.180]: TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits) mail | Oct 16 12:46:22 my_domain postfix/trivial-rewrite[1075]: warning: do not list domain my_domain.com.br in BOTH mydestination and virtual_mailbox_domains mail | Oct 16 12:46:23 my_domain policyd-spf[1077]: prepend Received-SPF: Permerror (mailfrom) identity=mailfrom; client-ip=209.85.222.180; helo=mail-qk1-f180.google.com; envelope-from=palves@informa.com.br; receiver=<UNKNOWN> mail | Oct 16 12:46:23 my_domain postfix/smtpd[1063]: NOQUEUE: reject: RCPT from mail-qk1-f180.google.com[209.85.222.180]: 550 5.1.1 <pablo@my_domain.com.br>: Recipient address rejected: User unknown in local recipient table; from=<palves@informa.com.br> to=<pablo@my_domain.com.br> proto=ESMTP helo=<mail-qk1-f180.google.com> mail | Oct 16 12:46:23 my_domain postfix/smtpd[1063]: disconnect from mail-qk1-f180.google.com[209.85.222.180] ehlo=2 starttls=1 mail=1 rcpt=0/1 data=0/1 quit=1 commands=5/7

erik-wramner commented 5 years ago

I think your problem is here:

warning: do not list domain my_domain.com.br in BOTH mydestination and virtual_mailbox_domains mail

Is your host name defined to be the domain name, by any chance?

The normal approach is to use a host name, for example but not necessarily mail, and then the domain name. The full name would be mail.somedomain.com where host name is mail and domain name is somedomain.com. If you set the options in your yaml file you shouldn't even need the OVERRIDE_HOSTNAME option, it should just work. The MX record should point to mail.somedomain.com which also needs an A record. You may keep another A record for somedomain.com without host name as well if you like.

Alternatively if you want to stick with your current configuration you could edit config/postfix-main.cf and add:

mydestination = localhost.$mydomain, localhost

That overrides the default which is:

mydestination = $myhostname, localhost.$mydomain, localhost

Restart. Hopefully that does the job. I would recommend the first approach. The second has worked for other users, but may have unforeseen issues.

digounet commented 5 years ago

It's worked!! thank you. I've changed the computer domain from my_domain.com.br to mail.my_domain.com.br, and changed the hostname and domain name in docker-compose.yml file to

hostname: mail domainname: my_domain.com.br