Open altustek opened 3 years ago
So, how this could look like?
Now, the mail processor part is the more complicated. To make it performant well with servers that have thousands of mailboxes maybe we'll need to have some kind of a queue database (or just a flag indicating which user's mailbox to look on). So it does not process all mailboxes all the time. Of course, it would have to have rights to access users mailboxes via imap (read the mail and append to Sent folder), and to send that mail.
It will be better to do "1" in terms of UI/UX, this will also match up with the competition (Gmail, Outlook). Actual implementation on the backend can be done as "2" "3" and "4", BUT definitely we don't want to send out X-Schedule or X-Send-On information to the recipient unless it is mandatory by some RFC standard. (Ref RFC 5322)
One implementation idea could be to put these messages to an outbox, with a "X-Send-On" header, and then have another script check the outbox and send on the scheduled time of each message and at that time strip the "X-send-on" header at the time of sending.
@alecpl I Guess this feature should be prioritized.
A "Schedule and Save" button (nearby the "Send" button) on mail compose page, that opens a dialog with some date/time setting form.
An "Outbox" (or "Scheduled Messages") folder to keep these messages in.
Store the date/time information somewhere. I guess it can be just an email header (e.g. X-Schedule or X-Send-On).
A mail processor program/script checking users' Outbox folders and sending the scheduled mail on specified time.
Implementation steps looks good. I also agree with @altustek about stripping any possible send-on header. For mail processor each user shouldn't be checked every time. Maybe flag implementation could save the day but a queue database solves problem completely and most efficiently. A priority queue could be handle this within O(log N) complexity. This shouldn't be a problem for any server.
Example Representation
{
["DATE__TIME", "USERNAME OF SENDER", "MAIL PATH OR IDENTIFIER**"]
["2024_02_19__16_55_00", "asandikci", "94710284410"]
["2024_02_19__16_56_00", "another_user", "24730254415"]
["2024_02_19__16_56_00", "another_user2", "34919289412"]
["2024_03_25__16_56_00", "another_user3", "4914242349"]
["2024_03_25__16_57_00", "another_user1", "719523523418"]
}
** I don't know how Roundcube identifies or stores mails, therefore I will just place random numbers for now
This priority queue database should be reverse sorted by DATE_TIME
argument. Roundcube should check this database's top element every minute (Complexity: O(1)). Until DATE_TIME
is equal with current time, Mail should be sent and data should be removed from database. In our example, When date is 2024_02_19__16_56_00
, mail 24730254415
of another_user
should be sent (or should be added to send-now queue), then this data should be deleted immediately (Complexity: O(logN)), then check again and also do same processes for another_user2
/34919289412
. If there is N mail with the same DATE_TIME, this process should last O(N * logN) in worst case. So there should not be a problem.
When someone creating a new scheduled mail new data should be added to this database (Complexity: O(logN))
Also Different Timezones should be handled but I didn't mention it on representation (Could be Implemented by converting each user date/time to server date/time)
Sorry for bad English, it is not my native language
i am looking for that feature too. seems there is only payed stuff out now at the moment. for sure it can be done with cron and manual scripts like with bash and some smtp credentials, but thats not really smart. is someone here who has some references to this issue? like existing github projects?
hi,
It will be great to have a elaborate feature to schedule emails for sending, instead of sending them right away.