1

I have a Symfony app (v4.3) running in an docker setup. This setup also has a container for the mailcatcher. No matter how I try to set the MAILER_URL in the .env file no mail shows up in the mailcatcher. If I just the call regular PHP mail() function the mails pops up in the mail catcher. The setup has been used for other projects as well and it worked without a flaw. Only with the Symfony Swiftmailer I can't the mails.

My docker-compose file looks like this:

version: '3'
services:
  #######################################
  # PHP application Docker container
  #######################################
  app:
    container_name: project_app
    build:
      context: docker/web
    networks:
      - default
    volumes:
      - ../project:/project:cached
      - ./etc/httpd/vhost.d:/opt/docker/etc/httpd/vhost.d
    # cap and privileged needed for slowlog
    cap_add:
      - SYS_PTRACE
    privileged: true
    env_file:
      - docker/web/conf/environment.yml
      - docker/web/conf/environment.development.yml
    environment:
      - VIRTUAL_HOST=.project.docker
      - POSTFIX_RELAYHOST=[mail]:1025
  #######################################
  # Mailcatcher
  #######################################
  mail:
    image: schickling/mailcatcher
    container_name: project_mail
    networks:
      - default
    environment:
      - VIRTUAL_HOST=mail.project.docker
      - VIRTUAL_PORT=1080

I pleayed around with the MAILER_URL setting hours but everything failed so far. Hope soembody here has an idea how to set the MAILER_URL.

Thank you

user13882309
  • 11
  • 1
  • 2

1 Answers1

1

According to docker-compose.yml, your MAILER_URL should be:

smtp://project_mail:1025

Double-check if it has the correct value

Then you can view container logs using docker-compose logs -f mail to see if your messages reach the service at all. It will be something like:

==> SMTP: Received message from '<user@example.com>' (619 bytes)

Second: try to restart your containers. Sometimes changes in .env* files are not applied instantly.

Dmitry Solovov
  • 303
  • 1
  • 2
  • 9
  • Thank you very much for your reply. Unfortunately it does not work. I set it as suggested, rebooted the containers and cleared the cache. When sending the mail there are no entries in the container mail log at all and no mail within the mailcatcher. – user13882309 Jul 09 '20 at 13:26
  • Are you sure mail is actually sent? Because swiftmailer will throw an exception if it cannot connect to smtp server. – Dmitry Solovov Jul 09 '20 at 13:35