takeyamajp / docker-postfix

The best Send-Only Email server
GNU General Public License v3.0
32 stars 7 forks source link

Recipient address rejected: Access denied #6

Closed hacker-h closed 1 year ago

hacker-h commented 1 year ago

I really like the project, but I am failing to send an example email; apparently some configuration is missing. Passing custom /etc/postfix configs seems to be impossible due to generation of those at runtime.

I am currently using the following bash script (domain changed to smtp.example.org):

FROM_ADDRESS="me@smtp.example.org"
TO_ADDRESS="henning.haecker+github.com@protonmail.com"
SUBJECT="Test-E-Mail"
BODY="Test E-Mail from Docker-Postfix-Container."

MAIL_SERVER="192.168.1.182"
MAIL_PORT=8587

EMAIL_FILE="$(mktemp)"
echo -e "From: $FROM_ADDRESS\nTo: $TO_ADDRESS\nSubject: $SUBJECT\n\n$BODY" > "$EMAIL_FILE"

if ! (echo -e "EHLO $MAIL_SERVER\nMAIL FROM: <$FROM_ADDRESS>\nRCPT TO: <$TO_ADDRESS>\nDATA\n$(cat "$EMAIL_FILE")\n.\n" | nc "$MAIL_SERVER" "$MAIL_PORT"); then
  echo "ERROR sending E-Mail."
  exit 1
fi
echo "E-Mail sent successfully"
rm "$EMAIL_FILE"

which produces this output:

$ bash send_mail.sh 
220 smtp.example.org ESMTP
250-smtp.example.org
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN CRAM-MD5
250-AUTH=PLAIN LOGIN CRAM-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 SMTPUTF8
250 2.1.0 Ok
554 5.7.1 <henning.haecker+github.com@protonmail.com>: Recipient address rejected: Access denied
554 5.5.1 Error: no valid recipients
221 2.7.0 Error: I can break rules, too. Goodbye.
E-Mail send successfully

Thankful for any assistance

takeyamajp commented 1 year ago

Hello hacker-h.

I believe you can use this Docker image to send emails using tagged addresses. The problem may be caused by the email server of the domain "protonmail.com" rejecting the tagged address "henning.haecker+github.com@protonmail.com" that you sent.

If you have more questions, can you show me the Docker logs when this container is running?

hacker-h commented 1 year ago

I also retried it without the label:

220 smtp.example.org ESMTP
250-smtp.example.org
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN CRAM-MD5
250-AUTH=PLAIN LOGIN CRAM-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 SMTPUTF8
250 2.1.0 Ok
554 5.7.1 <henning.haecker@protonmail.com>: Recipient address rejected: Access denied
554 5.5.1 Error: no valid recipients
221 2.7.0 Error: I can break rules, too. Goodbye.
E-Mail send successfully

here are the docker compose logs:

$ docker-compose up
Creating network "postfix_default" with the default driver
Creating postfix_postfix_1 ... done
Attaching to postfix_postfix_1
postfix_1  | default._domainkey IN  TXT ( "v=DKIM1; k=rsa; "
postfix_1  |      "p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8mrQ5gFZ9B3oWAIOP6ifoXjFQCVjPJxOb38Ena5uNX/DVHVqytqYYkAC1c3egF/4pu9SsjRAzzsYay9jcnEXvmjwpIfNtoUhv6SLl9j1ufa9k0wiXv1rzfXj8G49q7nGaB7dJRRaKXTnNzBgMNG1OHPtjO64ywsD5GaEjJ07KtwIDAQAB" )  ; ----- DKIM key default for xhacker.de
postfix_1  | 2023-06-11 18:24:08,053 INFO Included extra file "/etc/supervisord.d/opendkim.ini" during parsing
postfix_1  | 2023-06-11 18:24:08,053 INFO Included extra file "/etc/supervisord.d/postfix.ini" during parsing
postfix_1  | 2023-06-11 18:24:08,053 INFO Included extra file "/etc/supervisord.d/rsyslog.ini" during parsing
postfix_1  | 2023-06-11 18:24:08,053 INFO Included extra file "/etc/supervisord.d/tail.ini" during parsing
postfix_1  | 2023-06-11 18:24:08,053 INFO Set uid to user 0 succeeded
postfix_1  | 2023-06-11 18:24:08,072 INFO supervisord started with pid 1
postfix_1  | 2023-06-11 18:24:09,079 INFO spawned: 'tail' with pid 28
postfix_1  | 2023-06-11 18:24:09,080 INFO spawned: 'rsyslog' with pid 29
postfix_1  | 2023-06-11 18:24:09,082 INFO spawned: 'opendkim' with pid 30
postfix_1  | 2023-06-11 18:24:09,084 INFO spawned: 'postfix' with pid 31
postfix_1  | Jun 11 18:24:09 36c20201b8c1 opendkim[30]: OpenDKIM Filter v2.11.0 starting (args: -f -x /etc/opendkim.conf)
postfix_1  | 2023-06-11 18:24:09,291 INFO success: postfix entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
postfix_1  | Jun 11 18:24:09 36c20201b8c1 postfix/postfix-script[101]: starting the Postfix mail system
postfix_1  | Jun 11 18:24:09 36c20201b8c1 postfix/master[103]: daemon started -- version 3.5.8, configuration /etc/postfix
postfix_1  | 2023-06-11 18:24:09,962 INFO exited: postfix (exit status 0; expected)
postfix_1  | 2023-06-11 18:24:10,964 INFO success: tail entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
postfix_1  | 2023-06-11 18:24:10,965 INFO success: rsyslog entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
postfix_1  | 2023-06-11 18:24:10,966 INFO success: opendkim entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
postfix_1  | Jun 11 18:24:13 36c20201b8c1 postfix/submission/smtpd[106]: connect from ubuntu.fritz.box[192.168.0.10]
postfix_1  | Jun 11 18:24:13 36c20201b8c1 postfix/submission/smtpd[106]: improper command pipelining after EHLO from ubuntu.fritz.box[192.168.0.10]: MAIL FROM: <server@smtp.example.org>\nRCPT TO: <henning.haecker+github.com@protonmail.com>\nDATA\nFrom: 
postfix_1  | Jun 11 18:24:13 36c20201b8c1 postfix/submission/smtpd[106]: discarding EHLO keywords: CHUNKING
postfix_1  | Jun 11 18:24:13 36c20201b8c1 postfix/submission/smtpd[106]: NOQUEUE: reject: RCPT from ubuntu.fritz.box[192.168.0.10]: 554 5.7.1 <henning.haecker+github.com@protonmail.com>: Recipient address rejected: Access denied; from=<server@smtp.example.org> to=<henning.haecker+github.com@protonmail.com> proto=ESMTP helo=<server.fritz.box>
postfix_1  | Jun 11 18:24:13 36c20201b8c1 postfix/submission/smtpd[106]: warning: non-SMTP command from ubuntu.fritz.box[192.168.0.10]: From: server@smtp.example.org
postfix_1  | Jun 11 18:24:13 36c20201b8c1 postfix/submission/smtpd[106]: disconnect from ubuntu.fritz.box[192.168.0.10] ehlo=1 mail=1 rcpt=0/1 data=0/1 unknown=0/1 commands=2/5

postfix_1  | Jun 11 18:26:27 36c20201b8c1 postfix/submission/smtpd[112]: connect from ubuntu.fritz.box[192.168.0.10]
postfix_1  | Jun 11 18:26:27 36c20201b8c1 postfix/submission/smtpd[112]: improper command pipelining after EHLO from ubuntu.fritz.box[192.168.0.10]: MAIL FROM: <server@smtp.example.org>\nRCPT TO: <henning.haecker@protonmail.com>\nDATA\nFrom: server@smtp
postfix_1  | Jun 11 18:26:27 36c20201b8c1 postfix/submission/smtpd[112]: discarding EHLO keywords: CHUNKING
postfix_1  | Jun 11 18:26:27 36c20201b8c1 postfix/submission/smtpd[112]: NOQUEUE: reject: RCPT from ubuntu.fritz.box[192.168.0.10]: 554 5.7.1 <henning.haecker@protonmail.com>: Recipient address rejected: Access denied; from=<server@smtp.example.org> to=<henning.haecker@protonmail.com> proto=ESMTP helo=<server.fritz.box>
postfix_1  | Jun 11 18:26:27 36c20201b8c1 postfix/submission/smtpd[112]: warning: non-SMTP command from ubuntu.fritz.box[192.168.0.10]: From: server@smtp.example.org
postfix_1  | Jun 11 18:26:27 36c20201b8c1 postfix/submission/smtpd[112]: disconnect from ubuntu.fritz.box[192.168.0.10] ehlo=1 mail=1 rcpt=0/1 data=0/1 unknown=0/1 commands=2/5
takeyamajp commented 1 year ago

As you can see in the logs, it looks like the SMTP commands entered from your script are incorrect. The MAIL commands after the EHLO commands are both "MAIL FROM: <server@smtp.example.org>\nRCPT TO: <henning.haecker@protonmail.com>\nDATA\nFrom: server@smtp".

takeyamajp commented 1 year ago

If you still have problems, please reopen another issue.

hacker-h commented 1 year ago

I did not manage to produce a working hello world sample, could you please recommend me some code snippet to start from?

takeyamajp commented 1 year ago

Excuse me, but have you searched the internet for email sending scripts?

hacker-h commented 1 year ago

I tried a couple, but seems they are alle somehow buggy

takeyamajp commented 1 year ago

First of all, why don't you make a script that can be sent by Gmail, for example?