Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use docker-smtp with a WordPress container? #67

Open
silviubogan opened this issue May 2, 2020 · 3 comments
Open

How to use docker-smtp with a WordPress container? #67

silviubogan opened this issue May 2, 2020 · 3 comments

Comments

@silviubogan
Copy link

I have this in my docker-compose.yml (replace ... with anything valid):

wordpress:
    container_name: ...wordpress_1
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "80:80"
    volumes:
      - type: bind
        source: ./html
        target: /var/www/html
        volume:
          nocopy: true
    restart: "no"
    environment:
      WORDPRESS_DB_NAME: '...'
      WORDPRESS_DB_USER: '...'
      WORDPRESS_DB_PASSWORD: '...'
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_TABLE_PREFIX: 'wp_'
      WORDPRESS_AUTH_KEY: '...'
      WORDPRESS_SECURE_AUTH_KEY: '...'
      WORDPRESS_LOGGED_IN_KEY: '...'
      WORDPRESS_NONCE_KEY: '...'
      WORDPRESS_AUTH_SALT: '...'
      WORDPRESS_SECURE_AUTH_SALT: '...'
      WORDPRESS_LOGGED_IN_SALT: '...'
      WORDPRESS_NONCE_SALT: '...'

and this:

  smtp:
    image: namshi/smtp
    container_name: ...smtp_relay_1
    restart: "no"
    ports:
      - "25:25"

It seems that the SMTP is not accessible from the Contact Form 7 WordPress plugin which I use through the REST API. How can I test the smtp container in a fast and good way or how can I change the docker-compose.yml file to make it work?

When I run $ docker-compose up I do not get errors.

The JSON object I get in the browser is this:

{into: "#", status: "mail_failed", message: "There was an error trying to send your message. Please try again later."}

The related forum question is here.

Thank you.

@cottonthread
Copy link

cottonthread commented May 26, 2020

Hello,
Try run docker-compose logs -f ...smtp_relay_1 and see what was the reason. When it is not autorized you can find in his logs.

The parameter -f is for monitoring. So:

  1. Open your SSH and run docker-compose logs -f smtp
  2. With other SSH, enter to your Wordpress installation by runing docker-compose exec wordpress bash and do a ping to your smtp service, like: ping ...smtp_relay_1
  3. If you got response, so do an submit from your Contact Form 7 WordPress plugin. And monitor your smtp window
  4. Paste here what you saw in this window and let me see if I can give you some help. @silviubogan

@silviubogan
Copy link
Author

I tried your commands. This did not help me install the ping command, as you can see below.

$ docker-compose logs -f ...smtp_relay_1

(I replaced ... with the rest of the full name)

silviu@silviu-Inspiron-3537 /some/dir/path/here [1]> docker-compose logs -f ...smtp_relay_1
ERROR: No such service: ...smtp_relay_1

$ docker-compose logs -f smtp

silviu@silviu-Inspiron-3537 /some/dir/path/here [1]> docker-compose logs -f smtp
Attaching to ...smtp_relay_1
smtp_1        | + sed -ri '
smtp_1        | 	s/^#?(dc_local_interfaces)=.*/\1='\''[0.0.0.0]:25 ; [::0]:25'\''/;
smtp_1        | 	s/^#?(dc_other_hostnames)=.*/\1='\'''\''/;
smtp_1        | 	s/^#?(dc_relay_nets)=.*/\1='\''172.21.0.3\/16'\''/;
smtp_1        | 	s/^#?(dc_eximconfig_configtype)=.*/\1='\''internet'\''/;
smtp_1        | ' /etc/exim4/update-exim4.conf.conf
smtp_1        | + update-exim4.conf -v
smtp_1        | using non-split configuration scheme from /etc/exim4/exim4.conf.template
smtp_1        |     1 LOG: MAIN
smtp_1        |     1   exim 4.92 daemon started: pid=1, -q15m, listening for SMTP on port 25 (IPv6 and IPv4)
smtp_1        | + sed -ri '
smtp_1        | 	s/^#?(dc_local_interfaces)=.*/\1='\''[0.0.0.0]:25 ; [::0]:25'\''/;
smtp_1        | 	s/^#?(dc_other_hostnames)=.*/\1='\'''\''/;
smtp_1        | 	s/^#?(dc_relay_nets)=.*/\1='\''172.21.0.5\/16'\''/;
smtp_1        | 	s/^#?(dc_eximconfig_configtype)=.*/\1='\''internet'\''/;
smtp_1        | ' /etc/exim4/update-exim4.conf.conf
smtp_1        | + update-exim4.conf -v
smtp_1        | using non-split configuration scheme from /etc/exim4/exim4.conf.template
smtp_1        |     1 LOG: MAIN
smtp_1        |     1   exim 4.92 daemon started: pid=1, -q15m, listening for SMTP on port 25 (IPv6 and IPv4)

$ docker-compose exec wordpress bash

silviu@silviu-Inspiron-3537 /some/dir/path/here [1]> docker-compose exec wordpress bash
root@ee98931fa89e:/var/www/html# ping wordpress          
bash: ping: command not found
root@ee98931fa89e:/var/www/html# ping localhost:25 
bash: ping: command not found
root@ee98931fa89e:/var/www/html# apt-get install iputils-ping
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package iputils-ping
root@ee98931fa89e:/var/www/html# apt-get install ping        
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package ping
root@ee98931fa89e:/var/www/html# 

Thank you.

@cottonthread
Copy link

I tried your commands. This did not help me install the ping command, as you can see below.

$ docker-compose logs -f ...smtp_relay_1

(I replaced ... with the rest of the full name)

silviu@silviu-Inspiron-3537 /some/dir/path/here [1]> docker-compose logs -f ...smtp_relay_1
ERROR: No such service: ...smtp_relay_1

$ docker-compose logs -f smtp

silviu@silviu-Inspiron-3537 /some/dir/path/here [1]> docker-compose logs -f smtp
Attaching to ...smtp_relay_1
smtp_1        | + sed -ri '
smtp_1        | 	s/^#?(dc_local_interfaces)=.*/\1='\''[0.0.0.0]:25 ; [::0]:25'\''/;
smtp_1        | 	s/^#?(dc_other_hostnames)=.*/\1='\'''\''/;
smtp_1        | 	s/^#?(dc_relay_nets)=.*/\1='\''172.21.0.3\/16'\''/;
smtp_1        | 	s/^#?(dc_eximconfig_configtype)=.*/\1='\''internet'\''/;
smtp_1        | ' /etc/exim4/update-exim4.conf.conf
smtp_1        | + update-exim4.conf -v
smtp_1        | using non-split configuration scheme from /etc/exim4/exim4.conf.template
smtp_1        |     1 LOG: MAIN
smtp_1        |     1   exim 4.92 daemon started: pid=1, -q15m, listening for SMTP on port 25 (IPv6 and IPv4)
smtp_1        | + sed -ri '
smtp_1        | 	s/^#?(dc_local_interfaces)=.*/\1='\''[0.0.0.0]:25 ; [::0]:25'\''/;
smtp_1        | 	s/^#?(dc_other_hostnames)=.*/\1='\'''\''/;
smtp_1        | 	s/^#?(dc_relay_nets)=.*/\1='\''172.21.0.5\/16'\''/;
smtp_1        | 	s/^#?(dc_eximconfig_configtype)=.*/\1='\''internet'\''/;
smtp_1        | ' /etc/exim4/update-exim4.conf.conf
smtp_1        | + update-exim4.conf -v
smtp_1        | using non-split configuration scheme from /etc/exim4/exim4.conf.template
smtp_1        |     1 LOG: MAIN
smtp_1        |     1   exim 4.92 daemon started: pid=1, -q15m, listening for SMTP on port 25 (IPv6 and IPv4)

$ docker-compose exec wordpress bash

silviu@silviu-Inspiron-3537 /some/dir/path/here [1]> docker-compose exec wordpress bash
root@ee98931fa89e:/var/www/html# ping wordpress          
bash: ping: command not found
root@ee98931fa89e:/var/www/html# ping localhost:25 
bash: ping: command not found
root@ee98931fa89e:/var/www/html# apt-get install iputils-ping
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package iputils-ping
root@ee98931fa89e:/var/www/html# apt-get install ping        
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package ping
root@ee98931fa89e:/var/www/html# 

Thank you.

It seems that you haven't updated your apt repositore. So:

apt update && apt install -y iputils-ping , and then, ping your smtp container, acording to your log, it maybe ...smtp_relay_1.

Let's see if you can succes on ping your exim server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants