Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error control #1

Closed
lwcorp opened this issue Jan 19, 2025 · 5 comments
Closed

Add error control #1

lwcorp opened this issue Jan 19, 2025 · 5 comments

Comments

@lwcorp
Copy link

lwcorp commented Jan 19, 2025

There seems to be no error control, so if there's a failure it just returns an unknown reason:
Image
In my case, the unknown reason was solved by:

  1. Switch $bounce_mailbox_port to imap instead of pop3 and likewise use an IMAP port number rather than a POP3 one.
  2. Define an actual manual hostname in $bounce_mailbox_host instead of just localhost.

But I assume other errors might happen as well, so it might be best to try to determine the error, at least in a general way, especially as this plugin might come as default.

@bramley
Copy link
Owner

bramley commented Jan 19, 2025

"Unknown reason" wasn't to do with the mailbox port but the use of localhost. I have now included that in the plugin documentation.

But "Unknown reason" was exactly the case. The php function fsockopen() had not returned an error message

https://github.com/bramley/phplist-plugin-imap2/blob/master/plugins/Imap2/vendor/javanile/php-imap2/src/Roundcube/ImapClient.php#L1066

        $this->setError(self::ERROR_BAD, sprintf("Could not connect to %s:%d: %s",
            $host, $this->prefs['port'], $errstr ?: "Unknown reason"));

@lwcorp
Copy link
Author

lwcorp commented Jan 19, 2025

What a shame fsockopen returns no specific error. Don't you want to update the README here as well?

How about doing a simple #3?

@bramley
Copy link
Owner

bramley commented Jan 19, 2025

I don't want to duplicate documentation in that way.

php-imap2 is an external package so I also don't want to change that just for this specific issue.

@lwcorp
Copy link
Author

lwcorp commented Jan 19, 2025

What if you detect localhost even before calling the plugin, for example in .php-cs-fixer.php?

@bramley
Copy link
Owner

bramley commented Jan 19, 2025

I have added an explanation to the plugin documentation which I think is sufficient for the time being.

If this plugin became the basis of a long term solution for phplist to the issue of the removal of the IMAP extension then there could be some extra validation, such as the host name, protocol and port. I want to wait to see what that long term solution is going to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants