Had this issue with docker containers. Turns out I just need to add mailpit container to the shared network.