mail icon indicating copy to clipboard operation
mail copied to clipboard

Automatic out-of-office replies

Open nimishavijay opened this issue 3 years ago • 6 comments

Is your feature request related to a problem? Please describe.

It would be very useful to be able to set an automatic reply for a specified period of time, like if you are on vacation. All major email clients have this as a feature (Gmail, Thunderbird, Outlook, Apple Mail, Mailbird).

Describe the solution you'd like

In Gmail there is an option in the settings page where it can be set and configured. We can also have it in the account settings. image

Describe alternatives you've considered

N/a

Additional context

This can also tie in with the status, eg, if you set your status as vacationing, then for that period the out-of-office reply could be enabled automatically.

cc @jancborchardt @karlitschek

Implementation

We can do this via the Sieve vacation extension: https://datatracker.ietf.org/doc/html/draft-ietf-sieve-vacation-07

Writing the rule

As a minimal version we will add a form to the user interface where users can fill in the details of their vacation. From this information we will derive a Sieve script that is pushed to the Sieve server.

Reading the rule

Once a rule has been written and the UI is opened again, we will have to read back the contents of the active Sieve script and find out of it was written by this app or someone else. Then we have to read back the vacation details, or store them somewhere else, to hydrate the form.

We might have to add a hash comment or similar to the script to determine if the script was edited externally.

Updating the rule

Update is like write, we replace the full script.

Deleting the rule

Deleting the rule will erase the full script.

Design specification

Mockup of the settings UI if the server doesn't support Sieve

tbd

Mockup of the settings UI if there is an existing, incompatible Sieve script that we have to overwrite (data loss)

tbd

Mockup of the settings UI if Sieve is available but the vacation extension is not

tbd

Mockup of the settings UI if Sieve is available and there is no active script

tbd

nimishavijay avatar Aug 13 '21 08:08 nimishavijay

Great idea 👍

karlitschek avatar Aug 13 '21 08:08 karlitschek

This should be done on the server. We support Sieve. Sieve can do this :+1:

ChristophWurst avatar Aug 13 '21 08:08 ChristophWurst

This should be done on the server. We support Sieve. Sieve can do this +1

This will require some configuration system wide (or mail server wide if using provisionning?) to be sure admins can blacklist mails from being replied to:

  • blacklisted headers (and headers values)
  • blacklisted senders ..

Headers and footer for the replies might also need to be configured somewhere.

Also, it will require storing each sender that was replied to and the date it was done since for each user to be sure only one reply per day should be sent and avoid spamming.

Some resources: https://datatracker.ietf.org/doc/html/rfc3834 (rfc on automatic responses) http://www.onyxbits.de/gnarwl (Gnarwl - LDAP based email autoresponder, simple yet efficient that allows to blacklist headers, set headers and footers, etc.)

ArnY avatar Oct 31 '21 17:10 ArnY

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 30 '22 06:04 stale[bot]

I have updated the description with some details regarding implementation as well as mockups to design.

This can also tie in with the status

This seems like a critical point to clarify: where is the unavailability defined? As a user I do not want to set my absence in multiple places. Ideally this happens centrally. This could be somewhere in the personal Nextcloud settings, via special events in my calendar https://github.com/nextcloud/calendar/issues/3305 or similar. The user status and the OOO Mail reply are derived from this central information.

There seem to be alternative ideas like that the unavailability is defined in Mail and then creates a calendar entry.

One more thing to note is that with the example of Gmail there is always just one time frame where I can set myself absent. I can't proactively add all my vacations.

ChristophWurst avatar May 06 '22 11:05 ChristophWurst

The sieve rule that needs to be created:

require "fileinto";
require "date";
require "relational";
require "vacation";
# Dates need to be one lower than start
# and one higher than end to match
if allof(currentdate :value "gt" "date" "2022-08-09",
              currentdate :value "lt" "date" "2022-08-27"
    ) {
  vacation
    :from "Test Test <[email protected]>"
    :subject "SUBJECT HERE"
    # Changeable: reply once every x days you'll be out of office, in this case every day
    :days 1
    # Aliases should be includable
    # If a mail's recipient is not the envelope recipient and it's not on this list,
    # no vacation reply is sent for it.
    :addresses ["[email protected]", "[email protected]"]
  "TEXT HERE"

if there's some specific emails that should not get an OOO reply, they could be excluded by using

if not address "From" "[email protected]"

miaulalala avatar Aug 09 '22 10:08 miaulalala

Script insertion option 1 - require block + script block

# NEXTCLOUD MAIL - DO NOT EDIT
require "date";
require "relational";
require "vacation";
# END NEXTCLOUD MAIL - EDIT BELOW



## Generated by RoundCube Webmail SieveRules Plugin ##
require ["fileinto"];

# rule:[test]
if anyof (header :contains "Subject" "test")
{
        fileinto "INBOX";
}
# rule:[test2]
elsif anyof (header :contains "Subject" "t<C3><A4>st")
{
        fileinto "INBOX";
}

# Sentry
if address :is "from" "[email protected]" {
  fileinto "Sentry";
  stop; # vacation rule not processed
}



# NEXTCLOUD MAIL - DO NOT EDIT BELOW
# { "version": 1, "from":"2022-08-09", "to":"" }
if allof(currentdate :value "gt" "date" "2022-08-09",
              currentdate :value "lt" "date" "2022-08-27"
    ) {
  vacation
    :from "Test Test <[email protected]>"
    :subject "SUBJECT HERE"
    # Changeable: reply once every x days you'll be out of office, in this case every day
    :days 4
    # Aliases should be includable
    # If a mail's recipient is not the envelope recipient and it's not on this list,
    # no vacation reply is sent for it.
    :addresses ["[email protected]", "[email protected]"]
  "TEXT HERE"

Script insertion option 2 - one block

require ["mailbox", "fileinto", "date", "relational"];


# NEXTCLOUD MAIL - DO NOT EDIT
require "date";
require "relational";
require "vacation";
# { "from":"2022-08-09", "to":"" }
if allof(currentdate :value "gt" "date" "2022-08-09",
              currentdate :value "lt" "date" "2022-08-27"
    ) {
  vacation
    :from "Test Test <[email protected]>"
    :subject "SUBJECT HERE"
    # Changeable: reply once every x days you'll be out of office, in this case every day
    :days 1
    # Aliases should be includable
    # If a mail's recipient is not the envelope recipient and it's not on this list,
    # no vacation reply is sent for it.
    :addresses ["[email protected]", "[email protected]"]
  "TEXT HERE"
# END NEXTCLOUD MAIL - EDIT BELOW


# Sentry
if address :is "from" "[email protected]" {
  fileinto "Sentry";
  stop;
}

Notes

  • stop; stops any other rules
  • fileinto also skips vacation etc
  • If the script can't be saved (generic error) we show it to the user
    • Tell them they can edit manually
    • Optionally offer a script reset (with confirmation)

ChristophWurst avatar Aug 26 '22 13:08 ChristophWurst

@st3iny regarding enabling/disabling OOO and not losing the previous config. I suppose that if OOO is disabled we remove all of our script/require code but leave the metadata comment

ChristophWurst avatar Aug 26 '22 14:08 ChristophWurst

Is it actually possible that a Sieve server doesn't come with the vacation module? Can we check this somehow?

ChristophWurst avatar Aug 31 '22 18:08 ChristophWurst

Is it actually possible that a Sieve server doesn't come with the vacation module? Can we check this somehow?

I didn't find a way to check if the vacation module is enabled. It doesn't have to be available and might be disabled by admins (e.g. https://doc.dovecot.org/configuration_manual/sieve/extensions/vacation/).

I could imagine that saving the script will fail if the vacation module is disabled so we might show a warning to the user in this case.

st3iny avatar Sep 02 '22 09:09 st3iny

Okay then let's only catch script saving errors for now.

ChristophWurst avatar Sep 02 '22 12:09 ChristophWurst