How to move mail automatically from one folder to another

Discussion in 'General' started by pssadm, Jan 3, 2023.

  1. pssadm

    pssadm Member

    Hi guys, I hope this is the right place to post this inquiry. If not, I apologize. I'm wondering if there is a way to automatically move items in an IMAP folder to another IMAP folder as soon as there is anything detected in the source folder? I'm currently using Roundcube to manage rules and filtering, but I can SSH to the server and modify something manually if need be.

    The reason I ask is that Microsoft, in their infinite wisdom, decided to remove support for selecting the "Sent" items folder. So all sent messages on Outlook go into one folder and all messages sent by other devices go into another folder.

    Thank you for any help in advance. Happy New Year 2023 all!
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Did they really remove that? Which software are you using exactly?
  3. pssadm

    pssadm Member

    Yeah, I'm using Outlook 2016. Using ISPConfig w/Postfix/Dovecot as the IMAP server. The older version of Outlook would allow you to select the "special" folders like Drafts, Trash, & Sent. Well, that's gone now. So we have to do some fancy foot work to get around this.

    For those interested, I using Ubuntu Server and ended up installing inotifywait using
    sudo apt-get install inotifywait-tools
    Then also installed "incrontab". Using :
    sudo apt-get install incrontab
    Once installed create a incrontab entry. Type
    sudo incrontab -e
    Now add the contents below and adjust (,(username), and Folder names as desired.
    /var/vmail/ IN_MOVED_TO /usr/bin/doveadm -Dv move -u username@yourdomain Sent\ Messages mailbox Sent ALL
    For a bit more clarity on the incrontab entry above:
    The first part is the folder we want inotifywait to check for anything moved in. The second part is the command we want to run using dovecotadm .. which would then properly move any entry in the Microsoft chosen folder "Sent Messages" to the Sent folder I normally use on my other devices -- > "Sent".

    This basically scans the directory for any items moved into it. When it detects an entry it takes the action above. So while it works well enough.. it's still not a perfect solution for one reason. When I do want to search in Outlook for sent messages... the folder I use for sent messages shows the FROM address, (my email address), rather than the TO address. Making finding messages in Outlook difficult. No perfect solution yet. If anyone has a suggestion... It would be very much appreciated.

  4. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Be aware that incron is deprecated.
    ahrasis likes this.
  5. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

Share This Page