0

I have a docker wordpress website with WP mail SMTP plugin. I selected the default PHP

Emails are not sending. sending test email gives a 504 timeout error

php sendmail is installed

Dockerfile for wordpress

FROM wordpress:6.5.3-fpm


RUN \
    apt-get update && \
    apt-get install -y --no-install-recommends \
    libicu-dev \
    libldap2-dev \
    ssmtp && \
    docker-php-ext-install intl && \
    docker-php-ext-enable intl && \
    docker-php-ext-install shmop && \
    docker-php-ext-enable shmop

# modify ssmtp settings
RUN sed -ri -e 's/^(mailhub=).*/\1smtp-server/' \
    -e 's/^#(FromLineOverride)/\1/' /etc/ssmtp/ssmtp.conf

RUN \
    pecl install apcu && \
    docker-php-ext-enable apcu

compose:

version: '3.3'

services:
  db:
    image: mysql:8.0
    container_name: db
    restart: unless-stopped
    env_file: .env
    environment:
      MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD
      MYSQL_DATABASE: $MYSQL_DATABASE
      MYSQL_USER: $MYSQL_USER
      MYSQL_PASSWORD: $MYSQL_PASSWORD
    volumes:
      - dbdata:/var/lib/mysql
      - "/etc/localtime:/etc/localtime:ro"
    command: "--default-authentication-plugin=mysql_native_password"
    networks:
      - app-network

  wordpress:
    depends_on:
      - db
    # image: wordpress:6.5.3-fpm
    image: wp-custom
    build: build/wordpress/
    container_name: wordpress
    restart: unless-stopped
    env_file: .env
    ports:
      - "25:25"
      - "587:587"
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: $MYSQL_USER
      WORDPRESS_DB_PASSWORD: $MYSQL_PASSWORD
      WORDPRESS_DB_NAME: $MYSQL_DATABASE
    volumes:
      - wordpress_data:/var/www/html
      - ./settings/php/custom.ini:/usr/local/etc/php/conf.d/custom.ini
      - "/etc/localtime:/etc/localtime:ro"
    networks:
      - app-network

  webserver:
    container_name: nginx
    image: nginx:latest
    restart: always
    env_file: .env
    ports:
        - "8888:80"
    volumes:
      - wordpress_data:/var/www/html
      - ./settings/nginx-conf/default-dev.conf:/etc/nginx/conf.d/default.conf
      - "/etc/localtime:/etc/localtime:ro"
    networks:
      - app-network
    depends_on:
      - wordpress

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: pma
    platform: linux/amd64
    depends_on:
      - db
    links:
      - db
    environment:
      PMA_HOST: db
      PMA_USER: root
      PMA_PASSWORD: $MYSQL_ROOT_PASSWORD
      UPLOAD_LIMIT: 100M
      PMA_PORT: 3306
      PMA_ARBITRARY: 1
    restart: always
    ports:
      - 8080:80
    networks:
          - app-network

volumes:
  dbdata:
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: './local/database'
  wordpress_data:
    driver: local
    driver_opts:
      type: 'none'
      o: 'bind'
      device: './local/html'

networks:
  app-network:
    driver: bridge

log from test email

WP Mail SMTP
/var/www/html/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/TestTab.php (line: 350)

Backtrace:
[0] wp_mail called at [/var/www/html/wp-content/plugins/wp-mail-smtp/src/Admin/Pages/TestTab.php:350]
[1] WPMailSMTP\Admin\Pages\TestTab->process_post called at [/var/www/html/wp-content/plugins/wp-mail-smtp/src/Admin/ParentPageAbstract.php:265]
[2] WPMailSMTP\Admin\ParentPageAbstract->process_actions called at [/var/www/html/wp-includes/class-wp-hook.php:324]
[3] WP_Hook->apply_filters called at [/var/www/html/wp-includes/class-wp-hook.php:348]
[4] WP_Hook->do_action called at [/var/www/html/wp-includes/plugin.php:517]
[5] do_action called at [/var/www/html/wp-admin/admin.php:175]

1 Answer 1

-1

In my experience with setting up email services for WordPress sites, I found using the default PHPmailer can sometimes be less reliable than I would like. Let me share why and also discuss some alternatives based on my personal experiences with Amazon SES, Labnify SMTP, Mailgun, and Sendgrid.

One of the primary issues with PHPmailer is that its effectiveness heavily depends on your hosting server's mail configuration. If the server isn't properly set up to send emails or if it's on a shared hosting plan with strict limits, you might face issues such as your emails not being sent at all or landing in spam folders instead of inboxes.

Of course emails sent via PHPmailer often lack proper authentication headers like SPF (Sender Policy Framework), DKIM (DomainKeys Identified Mail), and DMARC (Domain-based Message Authentication, Reporting & Conformance). Without these crucial authentication mechanisms, many receiving mail servers may flag your emails as suspicious or spammy which severely affects email deliverability rates.

Another limitation comes from rate limits imposed by many shared hosts. These hosts typically restrict how many emails you can send per hour/day. Exceeding these limits could result in undelivered emails without any clear indication of failure besides clogging your queue in the server. So I would suggest something like Amazon SES, Labnify, Sendgrid, or Mailgun even if you have less traffic and customers to your website. It's always the best.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .