Skip to content

Add priority field to server #3446

Open
amirhasanzadehpy wants to merge 2 commits intopostalserver:mainfrom
QueraTeam:feature/server-priority-queue
Open

Add priority field to server #3446
amirhasanzadehpy wants to merge 2 commits intopostalserver:mainfrom
QueraTeam:feature/server-priority-queue

Conversation

@amirhasanzadehpy
Copy link

This introduces a server-level priority system to allow for more granular control over the message queue. By assigning a numerical priority to each mail server (with a higher number indicating higher priority), administrators can ensure that time-sensitive transactional emails are processed ahead of bulk newsletters or other less critical mail. This change modifies the message dequeuing logic to sort by server priority before the message ID, ensuring that all high-priority messages are sent first, while maintaining a fair first-in, first-out order for messages of the same priority. The feature is implemented with a default priority of 0 for all existing and new servers, making it a non-disruptive change that can be optionally configured after deployment.

@amirhasanzadehpy amirhasanzadehpy changed the title Add priority field to server model validation Add priority field to server Sep 23, 2025
@mjnaderi
Copy link

This PR resolves https://github.com/orgs/postalserver/discussions/1491

@adamcooke
Copy link
Contributor

I like the idea of this. I'll look at testing and merging this shortly.

@amirhasanzadehpy
Copy link
Author

I like the idea of this. I'll look at testing and merging this shortly.

I was wondering if there’s any update or feedback on this PR.

@mjnaderi
Copy link

Hi @adamcooke, just checking in to see if you’ve had a chance to review this yet. Happy to make any adjustments if needed!

Thanks again for taking a look.

@github-actions
Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale label Dec 28, 2025
@notz
Copy link

notz commented Dec 29, 2025

This is a very useful feature and should not be closed.

@github-actions github-actions bot removed the stale label Dec 30, 2025
michaeldoehler pushed a commit to relationsoftware/postal that referenced this pull request Jan 21, 2026
Adds a priority field to servers that controls the order in which
queued messages are processed. Messages from servers with higher
priority values are sent first.

Includes:
- Database migration to add priority column
- Validation for priority (0-32767)
- UI field in server form
- Queue ordering by server priority

Cherry-picked from postalserver/postal PR postalserver#3446

Co-authored-by: Xyaren <Xyaren@users.noreply.github.com>
Co-authored-by: openhands <openhands@all-hands.dev>
@kirik
Copy link

kirik commented Jan 28, 2026

Great idea, but my concern is that the implementation needs to be more sophisticated: imagine you have X emails with server priority 2 and Y emails with server priority 1. With a simple approach, none of the Y emails would be processed until all X emails are sent.

The solution is straightforward, similar to how operating systems manage CPU time: we should process messages while allocating more execution time to higher priority emails.

UPD: something like this #1422

@mjnaderi
Copy link

With a simple approach, none of the Y emails would be processed until all X emails are sent.

@kirik That is exactly what we need in our use case. We want to give higher priority to transactional emails, and no marketing email to be processed until all transactional emails are sent (sign up email verification, forget password, short-lived OTPs, ...).

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.

5 participants