tobybatch / kimai2

Docker containers for the kimai2 web application including docker-compose and kubernetes/helm deployment.
MIT License
183 stars 96 forks source link

[BUG] Emails not working #516

Closed vpanchal-code closed 10 months ago

vpanchal-code commented 1 year ago

Describe the bug Password reset emails are not working. Not sure what the issue is, postfix is not showing anything in the docker logs

Docker compose file (with passwords redacted)

version: "3.0"
networks:
  br0:
    name: br0
    external: true
volumes:
  kimaivar:
    name: kimaivar
    external: true
  kimaipublic:
    name: kimaipublic
    external: true
  kimaimysql:
    name: kimaimysql
    external: true
services:
  kimai_nginx:
    image: tobybatch/nginx-fpm-reverse-proxy:latest
    container_name: kimai_nginx
    ports:
      - 8008:80
    volumes:
      - kimaipublic:/opt/kimai/public:ro
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ:-America/New_York}
      - TRUSTED_HOSTS=${TRUSTED_HOSTS}
    restart: unless-stopped
    depends_on:
      - kimai
    healthcheck:
      test: wget --spider 192.168.1.4/health || exit 1
      interval: 20s
      start_period: 10s
      timeout: 10s
      retries: 3
    networks:
      br0:
        ipv4_address: 172.18.5.199
  kimai:
    image: kimai/kimai2:fpm-latest
    container_name: kimai
    depends_on:
      kimai_db:
        condition: service_healthy
    environment:
      - ADMINMAIL=${ADMINMAIL}
      - ADMINPASS=${ADMINPASS}
      - DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@kimai_db/${MYSQL_DATABASE}
      - TRUSTED_HOSTS=${TRUSTED_HOSTS}
      - TZ=${TZ:-America/New_York}
      - memory_limit=512M
    volumes:
      - kimaipublic:/opt/kimai/public
      - kimaivar:/opt/kimai/var
      # - /home/docker/kimai/local.yaml:/opt/kimai/config/packages/local.yaml
    restart: unless-stopped
    networks:
      br0:
        ipv4_address: 172.18.5.198
  kimai_phpmyadmin:
    image: phpmyadmin:latest
    container_name: kimai_phpmyadmin
    restart: always
    ports:
      - 8085:80
    environment:
      - PMA_ARBITRARY=1
    networks:
      br0:
        ipv4_address: 172.18.5.197
  kimai_swagger:
    image: swaggerapi/swagger-ui:latest
    container_name: kimai_swagger
    ports:
      - 8087:8080
    volumes:
      - /home/docker/kimai/swagger.json:/swagger.json
    environment:
      - SWAGGER_JSON=/swagger.json
    networks:
      br0:
        ipv4_address: 172.18.5.196
  kimai_postfix:
    image: catatnight/postfix:latest
    container_name: kimai_postfix
    environment:
      maildomain: simplementix.com
      smtp_user: ${SIMPLE_SMTP_USER}:${SIMPLE_SMTP_PASS}
      PUID: ${PUID}
      PGID: ${PGID}
      TZ: ${TZ:-America/New_York}
    restart: unless-stopped
    networks:
      br0:
        ipv4_address: 172.18.5.195
  kimai_db:
    image: mysql:5.7
    container_name: kimai_db
    ports:
      - 3306:3306
    environment:
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ:-America/New_York}
    volumes:
      - kimaimysql:/var/lib/mysql
    command: --default-storage-engine innodb
    restart: unless-stopped
    healthcheck:
      test: mysqladmin -p$$MYSQL_ROOT_PASSWORD ping -h localhost
      interval: 20s
      start_period: 10s
      timeout: 10s
      retries: 3
    networks:
      br0:
        ipv4_address: 172.18.5.194

Additional context Add any other context about the problem here.

tobybatch commented 1 year ago

Hi, This won't be a bug in the container, but it's an issue with the mailer you are using. I'm not sure I can help. Sorry.

tobybatch commented 1 year ago

But a quick looks shows you are not setting the:

      - MAILER_URL=smtp://mailer:1025
      - MAILER_FROM=kimai@example.com

https://www.kimai.org/documentation/emails.html

I'll uipdate tha sample docker-compose file to reflect that.

vpanchal-code commented 1 year ago

@tobybatch thank you, I was reading the documentation and added the default google email but it is not working. Does the MAILER_URL need to point to postfix container?

tobybatch commented 1 year ago

To be honest, I've not used that postix container in years. In the wild I point to my providers SMTP server. Look at the doc on the main Kimai site, this is just the container.

vpanchal-code commented 1 year ago

Ok, understood, no worries. I disabled postfix and tried using the Mailer URL and FROM setting on kimai container, since I am using a google email and do not need a high volume of emails being sent out. Also set the URL to not use the default and specify the mail server and port and TLS encryption and it still did not work.

Does the kimai docker image contain symfony/mailer installed as that is needed for emails to work on kimai?

kevinpapst commented 1 year ago

That is installed by default. Use smtps://{username}:{password}@smtp.gmail.com:465 for google instead of gmail+smtp://USERNAME:PASSWORD@default

vpanchal-code commented 1 year ago

@kevinpapst I changed it from smtp://{username}:{password}@smtp.gmail.com:587?encrpytion=tls to smtp://{username}:{password}@smtp.gmail.com:465 Also I tried with smtps:// instead of smtp:// and get the same result of 302 status code for the POST on the all of the URLs. Is 302 Status code the expected value for POST to the Mailer URL?

kevinpapst commented 1 year ago

I don't know what you ask, but that URL is not accessible. It is a DNS to describe the connection.

Kimai will only sent out password recovery emails every two hours by default, to protect spam. Just in case you try to test emails that way.

vpanchal-code commented 1 year ago

Ok, Ill will test in a few hours to make sure I do not hit the spam limit. Also I will check the DNS settings to make sure it is not causing any issues. Thank you for this insight. My testing may not be valid since I did not want to 2 hours. Will update this ticket with my results from testing over the next few hours.

kevinpapst commented 1 year ago

You can reset the status, it is described in the docs: https://www.kimai.org/documentation/emails.html#troubleshooting This way you can test it more often and don't have to wait for the expiration.

vpanchal-code commented 1 year ago

I tried workaround for the wait time by running docker-compose exec kimai /opt/kimai/bin/console doctrine:query:dql "UPDATE App\Entity\User u SET u.passwordRequestedAt = null WHERE u.username = 'test_user'" which results in no configuration file provided: not found

tobybatch commented 10 months ago

I'm going to close this as I don't think it's actual a container issue.