Invalid Host under Docker Swarm with PHPMailer

50 views Asked by At

I am configuring Open Journal System, that uses PHPMailer, on docker swarm. I have two images, one running php-fpm and the other postfix. From the php-fpm I am able to access the postfix one using the name declared on the docker swarm configuration, and I can even telnet to the port postfix is configured (and even send emails from bash).

Nevertheless, PHPMailer is complaining with invalid host, when my hostname is foo_postfix (the name of the docker container).

What might be going on?

Update

Looking into the code, the hostname is validated this way if (filter_var('http://' . $host, FILTER_VALIDATE_URL) !== false) and thus, it is failing.

So, probably I just need to guarantee these docker containers have a domain? Maybe there is a default domain for docker swarm containers?

FIX:

Not posting this as an answer, as I do not think it makes sense. But I solved the problem by adding an alias to the container:

    networks:
      netName
        aliases:
          - foo.postfix
          - foo_postfix

This way the PHP code accepts foo.postfix as a domain name.

0

There are 0 answers