Docker django + host posfix gives `Bad destination mailbox address: Address not recognized by gateway`

I'm trying to persuade containerized django to send emails using the postfix installation on my host, and I'm told Bad destination mailbox address: Address not recognized by gateway.

(For more detail, the django application I'm running is docker-zulip.)

When I trigger a password-recovery email, I expect the email to be sent, but my server log in the container (/var/log/zulip/server.log) reports:

2025-09-01 22:47:00.280 ERR  [zulip.send_email] Error sending password_reset email to ['User <user@gmail.com>'
]: {'User <user@gmail.com>': (550, b'5.1.1 Bad destination mailbox address: Address not recognized by gateway.
')}

I'm aware of the SO post How do you configure Django to send mail through Postfix?, and I'm using its prescribed settings. But that post doesn't focus on docker setups, so it looks as if something further is required.

Can the host send emails? Yes

I can send emails from the host easily enough using echo "BODY" | mailx -r test@example.com -s "SUBJECT" user@gmail.com.

Is postfix configured to recognize traffic from the container? I think so

I've configured /etc/postfix/main.cf in a way that I think supports my docker container (running on 172.18.0.100):

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 172.18.0.0/24
inet_interfaces =  172.17.0.1 172.18.0.1 172.23.0.1

...and I've run systemctl restart postfix.

I don't see any activity in the host logs /var/log/mail.{err,log}, though.

Вернуться на верх