Setting up SMTP in docker-compose for WordPress

Hello, I’m trying to enable WordPress SMTP mailing for Contact Form and Appointment plugins. My WordPress is running in a Docker container. My SMTP server needs to act like a mail relay.

I’m pretty sure I need a SMTP docker image with port configuration, but I’m not sure which image I need, and how to incorporate it in my docker-compose.

Here’s my docker-compose file

version: '3'

services:
  # Database
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: *******
      MYSQL_DATABASE: *******
      MYSQL_USER: *******
      MYSQL_PASSWORD: *******
    networks:
      - wpsite
  # phpmyadmin
  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - '8080:80'
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: *******
    networks:
      - wpsite
  # Wordpress
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - '8000:80'
    restart: always
    volumes: ['./:/var/www/html']
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: *******
      WORDPRESS_DB_PASSWORD: *******
    networks:
      - wpsite
networks:
  wpsite:
volumes:
  db_data:

Right now WP Mail SMTP returns this error:

An issue was detected.

This means your test email was unable to be sent.

Typically this error is returned for one of the following reasons:

- Plugin settings are incorrect (wrong SMTP settings, invalid Mailer configuration, etc).
- Your web server is blocking the connection.
- Your host is rejecting the connection.