Skip to content

Comments

Auto email Handling#1264

Open
cs2000 wants to merge 13 commits intoitflow-org:developfrom
cs2000:develop
Open

Auto email Handling#1264
cs2000 wants to merge 13 commits intoitflow-org:developfrom
cs2000:develop

Conversation

@cs2000
Copy link
Contributor

@cs2000 cs2000 commented Feb 9, 2026

Adds configurable post‑processing for parsed emails

Allows the user to select one of the following options

  • No Nothing (Leave as Unread)
  • No Nothing (Mark as Read)
  • Move to Folder
  • Delete

Improves O365 handling by using UID sequence and IMAP MOVE/COPY fallback + TRYCREATE folder creation.

Migration SQL

ALTER TABLE `settings`
  ADD COLUMN `config_imap_processed_action` varchar(50) DEFAULT 'move',
  ADD COLUMN `config_imap_processed_folder` varchar(200) DEFAULT 'ITFlow';

Notes for maintainers
New settings are read via load_global_settings.php
Stored by settings_mail.php
Used by ticket_email_parser.php

Upgrade process?
As far as i can tell, ITFlow does not currently auto‑apply schema migrations at runtime. The project typically expects:
manual SQL changes, or a versioned DB migration script

Adds options for auto handling of emails when processed by ticket_email_parser.php
Adds options for auto handling of emails when processed by ticket_email_parser.php
Adds options for auto handling of emails when processed by ticket_email_parser.php
Adds options for auto handling of emails when processed by ticket_email_parser.php
Adds options for auto handling of emails when processed by ticket_email_parser.php
@cs2000
Copy link
Contributor Author

cs2000 commented Feb 9, 2026

If there is a clean way to include the SQL changes, please let me know how you guys prefer to handle this and i will update my PR to match.

Also i should say, this has been verified with Microsoft 365, it is fully expected to work for Google, but not tested as i dont have a google environment setup to test with.

@wrongecho
Copy link
Collaborator

Hello, thank you for the PR. I will let @johnnyq go through the details but I just wanted to mention database updates should be made via database_updates.php.

Bumped database version to 2.4.1
Bumped database version to 2.4.1 and added migrations required to support this feature.
@cs2000
Copy link
Contributor Author

cs2000 commented Feb 9, 2026

Hello, thank you for the PR. I will let @johnnyq go through the details but I just wanted to mention database updates should be made via database_updates.php.

Thanks for that, i have made the changes in those files, appologies, i missed that!

@johnnyq
Copy link
Collaborator

johnnyq commented Feb 11, 2026

looks good, I like the move to custom folder name but the the other option should be left alone.

Currently only processed files that get moved to the itflow folder get marked read, no other emails are touched unless specifically opened with an email client.

@cs2000
Copy link
Contributor Author

cs2000 commented Feb 11, 2026

Sorry, it has been a long day, but im not sure i fully understand your comment.

The options i added should all work and are pretty standard in other ticket platforms. Some businesses want the emails to forever be in the inbox (why?!), some want them deleted (which is bad) and others like them marked as read and moved to a "processed" folder.

What i have seen in multiple MSP companies is there is a support@company.com email address which is purely used for incoming tickets, i personally see no reason why you would want them to be left unread asnd sat in the inbox folder (to me its a sanity check that the ticket has been seen by your ticting platform of choice and has been processed), but each to their own, hence the 4 choices.

Are you saying you'd like the other options removed except for Move to Custom Folder, or that you've tested them and they dont work?


As you can probably tell from my 2 commits, i come from an MSP background, more on the technical side the billing and so tickets have been my life for years. IT Flow is an amazing platform combining 3 (at least) different systems into one and im trying to bring the ticketing side of it on-par with some of the market leaders out there. I know these arent requested features (well, this isnt, OAuth most certainly was) but theyre nice quality of life things.

If you wanted to reach out at all and discuss your roadmap/ideas/wishes for the ticketing side of things i can possibly step in to help develop some of those, or im happy to keep submitting PR's for elements i personally feel are missing :)

I dont want to post my email in a comment (for want of not being spammed by bots) but its in section 2 of the license file for another project on my repo https://github.com/cs2000/DankDroneDownloader/blob/master/LICENSE

@git-kup
Copy link
Contributor

git-kup commented Feb 11, 2026

@cs2000 I am using shared mailboxes in MS365 will the new OAuth work with that?

also is there any chance if you could document the OAuth process at least for MS365 in the docs at https://docs.itflow.org/email_config

Thanks so much! Looking forward to!

@cs2000
Copy link
Contributor Author

cs2000 commented Feb 11, 2026

@cs2000 I am using shared mailboxes in MS365 will the new OAuth work with that?

also is there any chance if you could document the OAuth process at least for MS365 in the docs at https://docs.itflow.org/email_config

Thanks so much! Looking forward to!

Already done, but here https://docs.itflow.org/ticket_email_parse

as for shared mailboxes. Genuinely not sure, you need to be able to login to the mailbox to authorise OAuth, I will check if that can be done another way, but that’s not the subject of this PR.

@johnnyq
Copy link
Collaborator

johnnyq commented Feb 11, 2026

@cs2000 thats fantastic your credentials working for MSPs on both sides technical and billing fit quite well with our project and we appreciate your help.

Let me clarify a bit, You mentioned four options above:

  • No Nothing (Leave as Unread) -- Remove this option
  • No Nothing (Mark as Read) -- Remove this option
  • Move to Folder -- This is the only option we should have with a textbox with folder name defaulting to ITFlow
  • Delete -- This should not be an option we need to know what mail is being processed.

field config_imap_processed_action can be removed as it should automatically mark it as read and move to the specified folder.

We want to keep thing as simple and providing best defaults without providing an overwhelming number of options.

@git-kup this is different topic than OAUTH2 and shared mailboxes. You may be referring to this PR that was recently merged: #1261
the current is implementation of OAUTH2 is user flow based and not app flow based. App flow should allow more options and allow the use of a shared mailbox. This is for another day and another PR please correct me if i'm wrong @cs2000

@cs2000
Copy link
Contributor Author

cs2000 commented Feb 11, 2026

Thanks, understood, will work on this and resubmit.

Btw, is there any appetite for “canned replies” in the ticket system?

@johnnyq
Copy link
Collaborator

johnnyq commented Feb 11, 2026

Awesome @cs2000
Absolutely canned responses were a much requested feature on the forum a while ago
something the agent can select from a drop down and it would auto fill the comment.
Maybe with some predefined ones with the ability to add further canned responses

@johnnyq
Copy link
Collaborator

johnnyq commented Feb 11, 2026

Also we do have quite a few requested features on the forums https://forum.itflow.org/t/features
feel free to take a look and join in the discussions and open PRs. This will help us so much.

- Removed config_imap_processed_action column from fresh schema.
- Kept config_imap_processed_folder.
-Updated migration block (2.4.0 -> 2.4.1) to add only config_imap_processed_folder. Removed config_imap_processed_action.
- Removed loading of config_imap_processed_action
- Removed all action branching (delete, none, none_unread).
- Processed messages now always sets the 'Seen' flag and moves to configured folder (with existing O365 fallback/retry logic retained).
- Removed all read/validate/save handling for now deleted config_imap_processed_action.
- Saves only config_imap_processed_folder (defaults to ITFlow when blank).
- Removed the action dropdown (Do Nothing..., Delete, etc.).
- Kept only the folder textbox (config_imap_processed_folder, default ITFlow).
- Updated helper text to state fixed behavior: marked read + moved.
@sonarqubecloud
Copy link

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@cs2000
Copy link
Contributor Author

cs2000 commented Feb 12, 2026

All changes should now be made
image
The only remaining action is emails will be moved to the folder desired, the defailt is 'ITFlow'. If the box is blank and someone hits save it is normalized to ITFlow before saving.

Let me know if this is acceptable or if you'd prefer that if the box is blank it actually just gets marked as read and left in the inbox. I went with this option as you requested the removal of "Do Nothing (Mark as Read)".

@johnnyq
Copy link
Collaborator

johnnyq commented Feb 13, 2026

@cs2000 super! we'll review further

@johnnyq
Copy link
Collaborator

johnnyq commented Feb 13, 2026

Hello @cs2000
Wrongecho and I discussed this PR further and we decided that we want to keep things as minimal and clean as possible and cant really find a good use case scenario to have a custom folder. This should remain ITFlow.
I know you put alot of hard work into this PR and we do appreciate your work.

@cs2000
Copy link
Contributor Author

cs2000 commented Feb 13, 2026

No worries, it’s your code!

want me to just adjust the PR so it’s always ITFlow as the folder? I will leave some helper text behind stating that emails will be moved there but remove the text box? Or are you happy to roll this in your own way?

@wrongecho
Copy link
Collaborator

Hello. Please do take a moment to review our AI/LLM policy: https://docs.itflow.org/ai_llm_policy

@cs2000
Copy link
Contributor Author

cs2000 commented Feb 13, 2026

Hey @wrongecho i know you meant no offence by your comment, so I will explain.

I first found ITFlow in December 2025, installed it in Jan 26 and have been using it daily since. I am
However not 100% familiar with your codebase and code writing ‘style’.

For me, I have used LLM’s to get me a leg up in understanding your code base, learning where you prefer to do certain things etc and of course debugging when (inevitably) what you write first time round doesn’t quite work the way you want it to. The code I have submitted to you however is not AI generated.

In my stable of other projects are DankDroneDownloader.com, a site written probably 5 years ago now fully in PHP/MySQL and lately Drone-Hacks.com, this is not the same at all but a much more complex project than anything I have contributed to your code.

Whilst my style of writing may be different to yours, which is of course always going to be true, please don’t take my submissions as purely AI. As mentioned it was used where needed to bring me up to speed and to assist debugging, but not in code writing.

As mentioned though, this is your project, I am just trying to contribute and add some missing features from a vital component of your amazing work, however if you prefer I not do that, that’s your choice and one I would of course respect.

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 this pull request may close these issues.

4 participants