antedebaas / Viesti-Reports

DMARC & SMTP-TLS Reports processor and visualizer and BIMI file hoster
https://hub.docker.com/repository/docker/antedebaas/viesti-reports/general
GNU General Public License v2.0
75 stars 16 forks source link

Cannot create the attachments directory #51

Closed tobsowo closed 5 months ago

tobsowo commented 6 months ago

I am unable to retrieve mail and this is what I found in logs, can someone please share how I can get this resolved with docker installation?

NOTICE: PHP message: [critical] Error thrown while running command "app:getreportsfrommailbox". Message: "Cannot create the attachments directory "/var/www/html/var/imap/attachments""

tobsowo commented 6 months ago

2024/03/08 06:22:49 [error] 14#14: *1948 FastCGI sent in stderr: "PHP message: [critical] Error thrown while running command "app:getreportsfrommailbox". Message: "Cannot create the attachments directory "/var/www/html/var/imap/attachments""" while reading response header from upstream, client: 192.168.1.2, server: _, request: "GET /reports/checkmailnow HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:", host: "report.example.com", referrer: "https://report.example.com/" NOTICE: PHP message: [critical] Error thrown while running command "app:getreportsfrommailbox". Message: "Cannot create the attachments directory "/var/www/html/var/imap/attachments"" [critical] Error thrown while running command "app:getreportsfrommailbox". Message: "["TLS\/SSL failure for mail.example.com: SSL negotiation failed"]" In Imap.php line 712: ["TLS\/SSL failure for mail.bluespace.com.ng: SSL negotiation failed"] app:getreportsfrommailbox

bundyland commented 6 months ago

I'm not an expert in Docker, but it looks for me that there is an SSL error between your host and the mail host. How does your docker compose file look like? It should look like this:

environment: MAILER_HOST: my.mailhost.de MAILER_SMTPPORT: 587 MAILER_IMAPPORT: 993 MAILER_USER: my@mailbox.de MAILER_PASSWORD: myverystrongepassword

So maybe you should try different ports like 587 or 465 for smtp and 143 or 993 for imap. All depends on your mail host of course.

tobsowo commented 6 months ago

While troubleshooting I changed the SSL to a less secure reason for that.

This is what I have now

app:getreportsfrommailbox
  server: [CLOSED] IMAP connection broken (server response)"]                  
  ["IMAP SERVER BUG (invalid challenge): \"\"","Can not authenticate to IMAP   
In Imap.php line 712:
[critical] Error thrown while running command "app:getreportsfrommailbox". Message: "["IMAP SERVER BUG (invalid challenge): \"\"","Can not authenticate to IMAP server: [CLOSED] IMAP connection broken (server response)"]"

NOTICE: PHP message: [critical] Error thrown while running command "app:getreportsfrommailbox". Message: "["IMAP SERVER BUG (invalid challenge): \"\"","Can not authenticate to IMAP server: [CLOSED] IMAP connection broken (server response)"]"
tobsowo commented 6 months ago

This is my docker compose

name: dmarc-smtptls-reports
version: "2"
services:
  db:
    image: mariadb:latest
    environment:
      MYSQL_DATABASE: dmarcreports
      MYSQL_USER: dmarc
      MYSQL_PASSWORD: bE5^
      MYSQL_ROOT_PASSWORD: 4dhtf

    ports:
      - 3306
    restart: unless-stopped
    healthcheck:
      test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]
      interval: 10s
      timeout: 5s
      retries: 6

  web:
    image: antedebaas/dmarc-reports:latest
    ports:
        - 0.0.0.0:8080:8080
    environment:
      DATABASE_TYPE: mysql
      DATABASE_HOST: db
      DATABASE_PORT: 3306 
      DATABASE_NAME: dmarc
      DATABASE_USER: dmarc
      DATABASE_PASSWORD: bE5
      MAILER_HOST: mail.bl
      MAILER_SMTPPORT: 587
      MAILER_IMAPPORT: 993
      MAILER_USER: web
      MAILER_PASSWORD: PA
      DELETE_PROCESSED_MAILS: false
      ENABLE_REGISTRATION: false
      MAILCHECK_SCHEDULE: "15 * * * *"
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
bundyland commented 6 months ago

Can you connect to this mailbox with a regular mail client? Could you maybe try port 143 for imap? Just to check if your mail server works with STARTTLS.

tobsowo commented 6 months ago

I did connect with Outlook Desktop and worked perfectly and I have also tried port 143 on the docker but still did not work. After the checkmail runs for like two minutes, it ends up with the attached screenshot. image

bundyland commented 6 months ago

Oh, that makes it more complicated as I never have used Cloudflare for my mail host. I guess this is the problem, but let's wait if @antedebaas has more ideas.

Good luck!

tobsowo commented 6 months ago

When I disable Cloudflare, this is what I get. IMG_20240308_123933.jpg

antedebaas commented 6 months ago

one of the problems with the checkmail button is that it is bound to php-max-execution time. this is 30seconds by default. try running the command from the commandprompt instead.

tobsowo commented 6 months ago

Please what command do I run?

antedebaas commented 6 months ago

docker exec -t dmarc-web-1 php /var/www/html/bin/console app:getreportsfrommailbox

replace 'dmarc-web-1' with your container name

tobsowo commented 6 months ago

Thank you

antedebaas commented 6 months ago

let me know if this solved your issue

tobsowo commented 6 months ago

I ran into another issue

image

antedebaas commented 6 months ago

try the following command: php .\bin\console secit:imap:validate-connections

connection result should be success. if not check your configuration

tobsowo commented 6 months ago
/var/www/html # php /var/www/html/bin/console secit:imap:validate-connections
+------------+------------------------------------------------------------------------------------------------+-------------------------------------------+----------------------------+
| Connection | Connect Result                                                                                 | Mailbox                                   | Username                   |
+------------+------------------------------------------------------------------------------------------------+-------------------------------------------+----------------------------+
| default    | FAILED: Can not authenticate to IMAP server: [CLOSED] IMAP connection broken (server response) | {mail.webmail.com:993/imap/ssl}INBOX | webmaster@mail.com |
+------------+------------------------------------------------------------------------------------------------+-------------------------------------------+----------------------------+
Total connections: 1
/var/www/html # 
tobsowo commented 6 months ago

This is the result I get

antedebaas commented 6 months ago

Then the problem is on the mail server side