Unfortunately, that's a messy problem with no general solution.
There is no standard "vacation" feature in IMAP, so any implementation would be specific to a particular mail server setup. Depending on your mail server software, it could be simple or complicated.
Best,
Franzzup