Cannot connect to mailcow smtp server on the same machine

I am running Nextcloud AIO besides Mailcow, and am trying to get Nextcloud to connect to the Mailcow Postfix SMTP server. On other containers, i could add them to Mailcow’s docker network and send mail via <postfix-container-id>:587. Since i can’t add the Nextcloud container to the mailcow network, i tried adding the postfix container to the nextcloud-aio network, but this didnt work either. Thanks for any help!

Hi, see Email — Nextcloud latest Administration Manual latest documentation

If i use localhost, i get Connection could not be established with host "localhost:587": stream_socket_client(): Unable to connect to localhost:587 (Address not available)

Using mail.domain.com returns Connection could not be established with host "mail.domain.com:587": stream_socket_client(): Unable to connect to mail.domain.com:587 (Host is unreachable)

And with the container ID i get Connection could not be established with host "mailcowdockerized-postfix-mailcow-1:587": stream_socket_client(): php_network_getaddresses: getaddrinfo for mailcowdockerized-postfix-mailcow-1 failed: Try again

using netcat inside the nextcloud container, i can connect to mail.domain.com 80 but not mail.domain.com 587 (Host is unreachable)

OK so i had to add the mailcow postfix container to the nextcloud-aio docker network, and then add

"mail_smtpstreamoptions" => array(
    'ssl' => array(
        'allow_self_signed' => true,
        'verify_peer' => false,
        'verify_peer_name' => false
    )
),

to config.php. Now i am able to connect using the postfix container name as IP address.

1 Like