bokysan / docker-postfix

Multi architecture simple SMTP server (postfix null relay) host for your Docker and Kubernetes containers. Based on Debian/Ubuntu/Alpine.
MIT License
541 stars 149 forks source link

Postfix rejects email sent from container within local docker network #29

Closed redvivi closed 4 years ago

redvivi commented 4 years ago

Hello,

docker-postfix is rejecting email from local docker networks, despite being correctly detected in the network ranges. it seems that this issue is new.

Configuration (docker-compose)?

postfix: image: boky/postfix:v2.0.0 container_name: postfix restart: always environment: ALLOWED_SENDER_DOMAINS: 'mydomain.com' INBOUND_DEBUGGING: 1 volumes:

  • ./dkim_keys:/etc/opendkim/keys

I understand from the log that mydomain.mydomain_default is the container app trying to send an email through postfix. What I don't get is why there is no IP match postfix/smtpd[142]: match_hostaddr: smtpd_client_event_limit_exceptions: 172.18.0.2 ~? 172.16.0.0/12.

What did I try to solve the issue ?

I tried to force the 172.18.0.2/32 in mynetworks. Debugging to level > 3 doesn't give more info.

Logs

★★★★★ POSTFIX STARTING UP ★★★★★ ‣ INFO Not setting any timezone for the container ‣ INFO Using plain log format for rsyslog. ‣ INFO Using unlimited message size. ‣ INFO Setting smtp_tls_security_level: may ‣ NOTE Will try to deliver emails directly to the final server. Make sure your DNS is setup properly! ‣ INFO Using default private network list for trusted networks. ‣ NOTE Enabling additional debbuging for: 127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16, as INBOUND_DEBUGGING=''1'' ‣ INFO Setting up allowed SENDER domains: mydomain.com ‣ DEBUG DKIM_AUTOGENERATE not set -- you will need to provide your own keys. ‣ NOTE Configuring OpenDKIM. ...using socket inet:localhost:8891 ...for domain mydomain.com (selector: mail) ‣ INFO Applying custom postfix setting: message_size_limit=0 ‣ INFO Applying custom postfix setting: myhostname=149d38f40f89 ‣ INFO Applying custom postfix setting: mynetworks=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 ‣ NOTE Starting: rsyslog, postfix 2020-08-05 20:50:19,867 INFO Set uid to user 0 succeeded 2020-08-05 20:50:19,872 INFO supervisord started with pid 1 2020-08-05 20:50:20,875 INFO spawned: 'opendkim' with pid 63 2020-08-05 20:50:20,877 INFO spawned: 'master' with pid 64 2020-08-05 20:50:20,880 INFO spawned: 'rsyslog' with pid 65 2020-08-05T20:50:20.898936+00:00 INFO : [origin software="rsyslogd" swVersion="8.2004.0" x-pid="65" x-info="https://www.rsyslog.com"] start 2020-08-05 20:50:20,900 INFO success: master entered RUNNING state, process has stayed up for > than 0 seconds (startsecs) 2020-08-05T20:50:20.903270+00:00 INFO opendkim[70]: OpenDKIM Filter v2.10.3 starting (args: -D -f -x /etc/opendkim/opendkim.conf) 2020-08-05T20:50:21.638683+00:00 INFO postfix/postfix-script[137]: starting the Postfix mail system 2020-08-05T20:50:21.643391+00:00 INFO postfix/master[139]: daemon started -- version 3.5.2, configuration /etc/postfix 2020-08-05 20:50:21,644 INFO exited: master (exit status 0; expected) 2020-08-05 20:50:23,646 INFO success: rsyslog entered RUNNING state, process has stayed up for > than 2 seconds (startsecs) 2020-08-05 20:50:26,650 INFO success: opendkim entered RUNNING state, process has stayed up for > than 5 seconds (startsecs) 2020-08-05T20:51:20.053395+00:00 INFO postfix/smtpd[142]: connect from mydomain.mydomain_default[172.18.0.2] 2020-08-05T20:51:20.053424+00:00 INFO postfix/smtpd[142]: smtp_stream_setup: maxtime=300 enable_deadline=0 2020-08-05T20:51:20.053432+00:00 INFO postfix/smtpd[142]: match_hostname: smtpd_client_event_limit_exceptions: mydomain.mydomain_default ~? 127.0.0.0/8 2020-08-05T20:51:20.053438+00:00 INFO postfix/smtpd[142]: match_hostaddr: smtpd_client_event_limit_exceptions: 172.18.0.2 ~? 127.0.0.0/8 2020-08-05T20:51:20.054072+00:00 INFO postfix/smtpd[142]: match_hostname: smtpd_client_event_limit_exceptions: mydomain.mydomain_default ~? 10.0.0.0/8 2020-08-05T20:51:20.054083+00:00 INFO postfix/smtpd[142]: match_hostaddr: smtpd_client_event_limit_exceptions: 172.18.0.2 ~? 10.0.0.0/8 2020-08-05T20:51:20.054090+00:00 INFO postfix/smtpd[142]: match_hostname: smtpd_client_event_limit_exceptions: mydomain.mydomain_default ~? 172.16.0.0/12 2020-08-05T20:51:20.054095+00:00 INFO postfix/smtpd[142]: match_hostaddr: smtpd_client_event_limit_exceptions: 172.18.0.2 ~? 172.16.0.0/12 2020-08-05T20:51:20.054102+00:00 INFO postfix/smtpd[142]: report connect to all milters 2020-08-05T20:51:20.054114+00:00 INFO postfix/smtpd[142]: milter8_connect: non-protocol events for protocol version 6: 2020-08-05T20:51:20.054119+00:00 INFO postfix/smtpd[142]: milter8_connect: transport=inet endpoint=localhost:8891 2020-08-05T20:51:20.054144+00:00 INFO postfix/smtpd[142]: trying... [127.0.0.1] 2020-08-05T20:51:20.054224+00:00 INFO postfix/smtpd[142]: vstream_tweak_tcp: TCP_MAXSEG 21845 2020-08-05T20:51:20.054230+00:00 INFO postfix/smtpd[142]: fd=18: stream buffer size old=0 new=87380 2020-08-05T20:51:20.054236+00:00 INFO postfix/smtpd[142]: milter8_connect: my_version=0x6 2020-08-05T20:51:20.054732+00:00 INFO postfix/smtpd[142]: milter8_connect: my_actions=0x1ff SMFIF_ADDHDRS SMFIF_CHGBODY SMFIF_ADDRCPT SMFIF_DELRCPT SMFIF_CHGHDRS SMFIF_QUARANTINE SMFIF_CHGFROM SMFIF_ADDRCPT_PAR SMFIF_SETSYMLIST 2020-08-05T20:51:20.054754+00:00 INFO postfix/smtpd[142]: milter8_connect: my_events=0x1fffff SMFIP_NOCONNECT SMFIP_NOHELO SMFIP_NOMAIL SMFIP_NORCPT SMFIP_NOBODY SMFIP_NOHDRS SMFIP_NOEOH SMFIP_NR_HDR SMFIP_NOUNKNOWN SMFIP_NODATA SMFIP_SKIP SMFIP_RCPT_REJ SMFIP_NR_CONN SMFIP_NR_HELO SMFIP_NR_MAIL SMFIP_NR_RCPT SMFIP_NR_DATA SMFIP_NR_UNKN SMFIP_NR_EOH SMFIP_NR_BODY SMFIP_HDR_LEADSPC 2020-08-05T20:51:20.055226+00:00 INFO postfix/smtpd[142]: milter8_connect: milter inet:localhost:8891 version 6 2020-08-05T20:51:20.055234+00:00 INFO postfix/smtpd[142]: milter8_connect: events SMFIP_NOHELO SMFIP_NOUNKNOWN SMFIP_NODATA SMFIP_SKIP SMFIP_HDR_LEADSPC 2020-08-05T20:51:20.055240+00:00 INFO postfix/smtpd[142]: milter8_connect: requests SMFIF_ADDHDRS SMFIF_CHGHDRS SMFIF_SETSYMLIST 2020-08-05T20:51:20.055246+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: "j" 2020-08-05T20:51:20.055252+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: result "149d38f40f89" 2020-08-05T20:51:20.055257+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: "{daemon_name}" 2020-08-05T20:51:20.055262+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: result "149d38f40f89" 2020-08-05T20:51:20.055266+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: "{daemon_addr}" 2020-08-05T20:51:20.055272+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: result "172.18.0.4" 2020-08-05T20:51:20.055277+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: "v" 2020-08-05T20:51:20.055281+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: result "Postfix 3.5.2" 2020-08-05T20:51:20.055675+00:00 INFO postfix/smtpd[142]: milter_macrolookup: "" 2020-08-05T20:51:20.055690+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: result "mydomain.mydomain_default [172.18.0.2]" 2020-08-05T20:51:20.055697+00:00 INFO postfix/smtpd[142]: milter8_conn_event: milter inet:localhost:8891: connect mydomain.mydomain_default/172.18.0.2 2020-08-05T20:51:20.055705+00:00 INFO postfix/smtpd[142]: event: SMFIC_CONNECT; macros: j=149d38f40f89 {daemon_name}=149d38f40f89 {daemonaddr}=172.18.0.4 v=Postfix 3.5.2 =mydomain.mydomain_default [172.18.0.2] 2020-08-05T20:51:20.056002+00:00 INFO postfix/smtpd[142]: reply: SMFIR_CONTINUE data 0 bytes 2020-08-05T20:51:20.056012+00:00 INFO postfix/smtpd[142]: > mydomain.mydomain_default[172.18.0.2]: 220 149d38f40f89 ESMTP Postfix 2020-08-05T20:51:20.056020+00:00 INFO postfix/smtpd[142]: watchdog_pat: 0x558e40a0b350 2020-08-05T20:51:20.056257+00:00 INFO postfix/smtpd[142]: < mydomain.mydomain_default[172.18.0.2]: EHLO [127.0.0.1] 2020-08-05T20:51:20.056269+00:00 INFO postfix/smtpd[142]: report helo to all milters 2020-08-05T20:51:20.056274+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: "{tls_version}" 2020-08-05T20:51:20.056280+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: "{cipher}" 2020-08-05T20:51:20.056284+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: "{cipher_bits}" 2020-08-05T20:51:20.056289+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: "{cert_subject}" 2020-08-05T20:51:20.056294+00:00 INFO postfix/smtpd[142]: milter_macro_lookup: "{cert_issuer}" 2020-08-05T20:51:20.056300+00:00 INFO postfix/smtpd[142]: milter8_helo_event: milter inet:localhost:8891: helo [127.0.0.1] 2020-08-05T20:51:20.056305+00:00 INFO postfix/smtpd[142]: event: SMFIC_HELO; macros: (none) 2020-08-05T20:51:20.056311+00:00 INFO postfix/smtpd[142]: skipping event SMFIC_HELO for milter inet:localhost:8891 2020-08-05T20:51:20.056319+00:00 INFO postfix/smtpd[142]: match_list_match: mydomain.mydomain_default: no match 2020-08-05T20:51:20.056616+00:00 INFO postfix/smtpd[142]: match_list_match: 172.18.0.2: no match 2020-08-05T20:51:20.056631+00:00 INFO postfix/smtpd[142]: > mydomain.mydomain_default[172.18.0.2]: 250-149d38f40f89 2020-08-05T20:51:20.056638+00:00 INFO postfix/smtpd[142]: > mydomain.mydomain_default[172.18.0.2]: 250-PIPELINING 2020-08-05T20:51:20.056643+00:00 INFO postfix/smtpd[142]: > mydomain.mydomain_default[172.18.0.2]: 250-SIZE 2020-08-05T20:51:20.056648+00:00 INFO postfix/smtpd[142]: > mydomain.mydomain_default[172.18.0.2]: 250-VRFY 2020-08-05T20:51:20.056654+00:00 INFO postfix/smtpd[142]: > mydomain.mydomain_default[172.18.0.2]: 250-ETRN 2020-08-05T20:51:20.056659+00:00 INFO postfix/smtpd[142]: > mydomain.mydomain_default[172.18.0.2]: 250-ENHANCEDSTATUSCODES 2020-08-05T20:51:20.056664+00:00 INFO postfix/smtpd[142]: > mydomain.mydomain_default[172.18.0.2]: 250-8BITMIME 2020-08-05T20:51:20.056670+00:00 INFO postfix/smtpd[142]: > mydomain.mydomain_default[172.18.0.2]: 250-DSN 2020-08-05T20:51:20.056675+00:00 INFO postfix/smtpd[142]: > mydomain.mydomain_default[172.18.0.2]: 250 CHUNKING 2020-08-05T20:51:20.056682+00:00 INFO postfix/smtpd[142]: watchdog_pat: 0x558e40a0b350 2020-08-05T20:51:20.057413+00:00 INFO postfix/smtpd[142]: < mydomain.mydomain_default[172.18.0.2]: QUIT 2020-08-05T20:51:20.057421+00:00 INFO postfix/smtpd[142]: > mydomain.mydomain_default[172.18.0.2]: 221 2.0.0 Bye 2020-08-05T20:51:20.057429+00:00 INFO postfix/smtpd[142]: match_hostname: smtpd_client_event_limit_exceptions: mydomain.mydomain_default ~? 127.0.0.0/8 2020-08-05T20:51:20.057434+00:00 INFO postfix/smtpd[142]: match_hostaddr: smtpd_client_event_limit_exceptions: 172.18.0.2 ~? 127.0.0.0/8 2020-08-05T20:51:20.057441+00:00 INFO postfix/smtpd[142]: match_hostname: smtpd_client_event_limit_exceptions: mydomain.mydomain_default ~? 10.0.0.0/8 2020-08-05T20:51:20.057445+00:00 INFO postfix/smtpd[142]: match_hostaddr: smtpd_client_event_limit_exceptions: 172.18.0.2 ~? 10.0.0.0/8 2020-08-05T20:51:20.057451+00:00 INFO postfix/smtpd[142]: match_hostname: smtpd_client_event_limit_exceptions: mydomain.mydomain_default ~? 172.16.0.0/12 2020-08-05T20:51:20.057456+00:00 INFO postfix/smtpd[142]: match_hostaddr: smtpd_client_event_limit_exceptions: 172.18.0.2 ~? 172.16.0.0/12 2020-08-05T20:51:20.057462+00:00 INFO postfix/smtpd[142]: abort all milters 2020-08-05T20:51:20.057467+00:00 INFO postfix/smtpd[142]: milter8_abort: abort milter inet:localhost:8891 2020-08-05T20:51:20.057473+00:00 INFO postfix/smtpd[142]: disconnect event to all milters 2020-08-05T20:51:20.057721+00:00 INFO postfix/smtpd[142]: milter8_disc_event: quit milter inet:localhost:8891 2020-08-05T20:51:20.057892+00:00 INFO postfix/smtpd[142]: disconnect from mydomain.mydomain_default[172.18.0.2] ehlo=1 quit=1 commands=2 2020-08-05T20:51:20.057898+00:00 INFO postfix/smtpd[142]: free all milters 2020-08-05T20:51:20.057902+00:00 INFO postfix/smtpd[142]: free milter inet:localhost:8891

Do you confirm there is an issue ?

redvivi commented 4 years ago

Malformed email from the client, no issue on postfix.