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

Mail Check issue #684

Open
1 of 2 tasks
miko007 opened this issue Jul 31, 2024 · 2 comments
Open
1 of 2 tasks

Mail Check issue #684

miko007 opened this issue Jul 31, 2024 · 2 comments
Labels

Comments

@miko007
Copy link

miko007 commented Jul 31, 2024

Is this a BUG REPORT or FEATURE REQUEST?:

  • BUG
  • FEATURE

What happened:
I tried to setup mail check with our inbox. the mails get read, but no tickets are created.

What did you expect to happen:
trudesk to fetch unread mails and create tickets from them

How to reproduce it (as minimally and precisely as possible):
set up mail check and try to create a ticket by sending an email to the configured mail account.

Anything else we need to know?:
This seems to be some race condition in the imap library. i put some debug lines into src/mailer/mailCheck.js:

...
                          if (_.isUndefined(mail.textAsHtml)) {
                            var $ = cheerio.load(mail.html)
                            var $body = $('body')
                            message.body = $body.length > 0 ? $body.html() : mail.html
 
                          } else {
                            message.body = mail.textAsHtml
                          }
 
      console.log("--------- PUSHING TICKET", message);
                          mailCheck.messages.push(message)
                        })
                      })
                    })
                  })
 
                    f.once('end', () => {
     console.log("----------- MESSAGES", mailCheck.messages);
                    mailCheck.Imap.addFlags(results, flag, function () {
                      mailCheck.Imap.closeBox(true, function () {
                        mailCheck.Imap.end()
                        handleMessages(mailCheck.messages, function () {
                          mailCheck.Imap.destroy()
                        })
                      })
                    })
...

this showed, that the f.once('end') event is fired before all messages have been processed. the mailCheck.messages array is empty at that point, although it gets filled correctly.

to further solidify my theory, i packed the callback of f.once('end') into a timeout:

                    f.once('end', () => {
                          setTimeout(() => {
 
     console.log("----------- MESSAGES", mailCheck.messages);
                    mailCheck.Imap.addFlags(results, flag, function () {
                      mailCheck.Imap.closeBox(true, function () {
                        mailCheck.Imap.end()
                        handleMessages(mailCheck.messages, function () {
                          mailCheck.Imap.destroy()
                        })
                      })
                    })
                          }, 2000);

after this, mail check worked as expected. i do not know the codebase well enough to suggest if this is some logic error inside mailCheck.js or a bug in the imap library, but one or the other is most likely the case.

Environment:

  • Trudesk Version: current master
  • OS (e.g. from /etc/os-release): CentOS 7
  • Node.JS Version: v20.15.1
  • MongoDB Version: --
  • Is this hosted on cloud.trudesk.io: no
@polonel polonel added the backlog label Aug 9, 2024
@benowe1717
Copy link

I just deployed Trudesk through the sample docker-compose.yaml file and I am experiencing a similar issue. The emails in my configured inbox are marked as read (or deleted if I enable the setting) but no ticket is created. I thought it was because a User did not exist, so I created one, but that hasn't affected the outcome.

Environment:

  • Trudesk Version: 1.2.11
  • OS: Docker version 24.0.1, build 6802122 (running on Debian GNU/Linux 11 (bullseye))
  • Node.JS Version: v16.14.2 (got this from inside the trudesk container image)
  • MongoDB Version: v5.0.31
  • Is this hosted on cloud.trudesk.io: no
  • Email: self-hosted with Dovecot in Docker

I'm more than happy to provide any and all additional information if it helps! Also, if I should create a new issue instead of piling a comment on then I'm happy to do that as well, apologies in advance for any trouble!

@miko007
Copy link
Author

miko007 commented Mar 18, 2025

that is fine, i think, as you are describing the exact same issue. as @polonel moved this to backlog, this issue unfortunately seems to be not very high on the priority list.

maybe not a lot of users are using the mail functionality, but for us this is a key feature we can not do without. I would go so far to say, that without this feature one does not really have a ticket system, but more of an issue tracker.

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

No branches or pull requests

3 participants