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

IMAP - No unseen emails (because of " around date in query" #4175

Closed
skilltryck opened this issue Aug 10, 2024 · 8 comments
Closed

IMAP - No unseen emails (because of " around date in query" #4175

skilltryck opened this issue Aug 10, 2024 · 8 comments

Comments

@skilltryck
Copy link

PHP version: 7.4/8.3
FreeScout version: 1.8.148
Database: MySQL
Are you using CloudFlare: No
Are you using non-official modules: No

After upgrading to 1.8.148 no new emails came.
After troubleshooting some time I found the problem to be with the query to our IMAP server.

UID SEARCH SINCE "7-Aug-2024" UNSEEN returned empty
UID SEARCH SINCE 7-Aug-2024 UNSEEN returned correctly

Changed in overrides/webklex/php-imap/src/Query/Query.php

if (is_numeric($statement[1])) {
  $query .= $statement[0] . ' ' . $statement[1];
} else {
  $query .= $statement[0] . ' "' . $statement[1] . '"';
}

to:

if (is_numeric($statement[1])) {
  $query .= $statement[0] . ' ' . $statement[1];
 } else if ($statement[0] == 'SINCE') {
  $query .= $statement[0] . ' ' . $statement[1];
} else {
  $query .= $statement[0] . ' "' . $statement[1] . '"';
 }

Is a workaround for me.
There is probably a much better solution though...

@freescout-help
Copy link
Collaborator

Which mail server are you using?

@freescout-help
Copy link
Collaborator

freescout-help commented Aug 11, 2024

We've noticed that your date 7-Aug-2024 is missing a leading zero.

Try to hardcode the following and check if this is the reason of your issue:

} else if ($statement[0] == 'SINCE') {
  $query .= $statement[0] . ' "07-Aug-2024"';

@skilltryck
Copy link
Author

Which mail server are you using?

Using an old server, Eudora Internet Mail Server.

@skilltryck
Copy link
Author

We've noticed that your date 7-Aug-2024 is missing a leading zero.

Try to hardcode the following and check if this is the reason of your issue:

} else if ($statement[0] == 'SINCE') {
  $query .= $statement[0] . ' "07-Aug-2024"';

Same problem.
Still works without quotes around the date.

Looks in RFC that dates following SINCE is used without quotes.
https://www.rfc-editor.org/rfc/rfc3501

@freescout-help
Copy link
Collaborator

We've changed it in the master branch. It will be published in the next release.

@freescout-help
Copy link
Collaborator

Did you have some error in logs when the date was enclosed in quotes?

freescout-help-desk added a commit that referenced this issue Aug 16, 2024
…P_SINCE_WITHOUT_QUOTES_ON_FETCHING env parameter - closes #4175
@skilltryck
Copy link
Author

Did you have some error in logs when the date was enclosed in quotes?

No errors, just wrong result.
Instead of returning UIDs of UNSEEN messages I got an empty response from IMAP-server.

@freescout-help
Copy link
Collaborator

Starting from FreeScout v1.8.150 you need to set APP_SINCE_WITHOUT_QUOTES_ON_FETCHING=true parameter in the .env file and clear cache.

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

No branches or pull requests

2 participants