antedebaas / Viesti-Reports

DMARC & SMTP-TLS Reports processor and visualizer and BIMI file hoster
https://docs.viestireports.com/
GNU Affero General Public License v3.0
82 stars 16 forks source link

Unable to Read Mailbox - Exchange 2016 #105

Closed diver2567 closed 1 month ago

diver2567 commented 5 months ago

Are you using the Docker image?

Database used

Error Messages 2024/06/07 09:41:29 [error] 19#19: *3 FastCGI sent in stderr: "PHP message: [critical] Error thrown while running command "app:getreportsfrommailbox". Message: "Could not search mailbox!"" while reading response header from upstream, client: 10.132.34.57, server: _, request: "GET /reports/checkmailnow HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:",

Steps to Reproduce Please provide detailed steps to reproduce the problem: Start Docker Image with docker-compose.yml file modified for IMAP and MYSQL. Open panel interface and create admin account. Login to admin account and click Check Mailbox (then the above error is shown within the output when performing docker compose up (rather then -d).

Expected behavior Reads mailbox and provides output into the panel.

Environment (please complete the following information):

antedebaas commented 5 months ago

Which port and encryption method do you use for the imap connection?

diver2567 commented 5 months ago

Which port and encryption method do you use for the imap connection?

Hi Antedebaas, thank you for the response on this.

I had this set to IMAP 993 SSL, I also tried 143 non SSL but that did not work either.

IMAP is working correctly, I've been testing parsemarc's docker version however it's a big docker for a small operation and ideally would like to use your one as it contains the login page for security.

Let me know if there's anything else I can add.

antedebaas commented 5 months ago

Could you try 993 using starttls?

diver2567 commented 5 months ago

Could you try 993 using starttls?

I've spun up parsecmarc dockerized which seems to be working okay.

How do you state starttls within the software? Originally I thought it would be a IMAP issue but given the parsec one is working it would seem it something on the software?

Thanks again and apologises for the delay.

antedebaas commented 5 months ago

I think there is something wrong with the way I connect to the mailserver. But since it works on my server I don’t see what’s wrong. I need to investigate this further

antedebaas commented 5 months ago

@tobsowo could you let me know what your authentication security was in #51 ? (or your desired level as i remember) i want to take that along with this issue

antedebaas commented 5 months ago

Note to self. Try encoding

tobsowo commented 5 months ago

This is what I see on my mail server log

2024-06-25T00:42:55.281118Z  INFO session{instance="smtp" protocol=Smtp remote.ip="178.xxx.xxx.xx" remote.port=59033}: smtp::inbound::ehlo: context="ehlo" event="reject" reason="invalid" domain="User"
antedebaas commented 5 months ago

@tobsowo what port are you using with what encryption that does not work with this project

tobsowo commented 5 months ago

587 & 993

antedebaas commented 4 months ago

@tobsowo @diver2567

And with what encryption/ssl/tls settings?

and what is the value of MAILBOX_CONNECTION in the .env.local file?

tobsowo commented 4 months ago

I just checked and I do not have any MAILBOX_CONNECTION value. WHat value do I add?

antedebaas commented 4 months ago

/var/www/html/.env.local will always contain that line. It can’t work without it and is auto generated on container startup

tobsowo commented 4 months ago

@antedebaas another thing is this, before now I uses WildDuck for mail server but since I switched to Stalwart I have not been able to connect my mailbox.

Maybe you could install and try in your environment.

https://stalw.art

Littlericket commented 2 months ago

I had the same issue for Exchange 2016, resulting in an error message like the one reported. In my case it was some hidden charset issue. I've fixed that by patching the getreportsfrommailbox-command, function "open_mailbox" and adding a charset switch to it. Don't know if this helps here or maybe should be implemented in the app itself, kinda hacky but it works here.

        try {
            retry:
            $mail_ids = $mailbox->searchMailbox('UNSEEN');
        } catch (\Exception $e) {
            if (strpos($e, " [BADCHARSET (US-ASCII)]")) {
                $oldEncoding = $mailbox->getServerEncoding();
                $mailbox->setServerEncoding('US-ASCII');
                $newEncoding = $mailbox->getServerEncoding();

                $log = new Logs;
                $log->setTime(new \DateTime);
                $log->setMessage("Encoding changed dynamically from {$oldEncoding} to {$newEncoding}");
                $this->em->persist($log);
                $this->em->flush();

                goto retry;
            } else {
                error_log($e);
                throw $e;
            }
        }

Produces encoding messages in log like Encoding changed dynamically from UTF-8 to US-ASCII

antedebaas commented 1 month ago

Since exchange 2016 is out of support by next year I’m not gonna put any effort into this.