roundcube / roundcubemail

The Roundcube Webmail suite
https://roundcube.net
GNU General Public License v3.0
5.66k stars 1.61k forks source link

Enhancement: Scheduled Send AND/OR scheduled "outbox processing" #8110

Open altustek opened 3 years ago

altustek commented 3 years ago

hi,

It will be great to have a elaborate feature to schedule emails for sending, instead of sending them right away.

  1. This strategically reduces, the overall email traffic, and also improves the work ethic on part of the users/consumers.
  2. It allows for re-editing of the email if the sender wants to edit it before it is sent... If an elaborate system (better than gmail) is hard to implement, one could have a "outbox", and the mail processor can send out the outbox to the SMTP server at designated times/intervals instead. That way the "sent" emails will live in the outbox for some used pre-configured time before they are sent out.
alecpl commented 3 years ago

So, how this could look like?

  1. A "Schedule and Save" button (nearby the "Send" button) on mail compose page, that opens a dialog with some date/time setting form.
  2. An "Outbox" (or "Scheduled Messages") folder to keep these messages in.
  3. Store the date/time information somewhere. I guess it can be just an email header (e.g. X-Schedule or X-Send-On).
  4. A mail processor program/script checking users' Outbox folders and sending the scheduled mail on specified time.

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.

altustek commented 3 years ago

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.

asandikci commented 6 months ago

@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

vmario89 commented 2 weeks ago

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?