I can’t get sieve filters to “send a copy” to another email address.
This is a brand new installation of HestiaCP and I added sieve to the installation script.
I restored several users from my VestaCP server and noticed that managesieve rules were not in the same place so I manually moved and changed permissions and created sym links. Once I had the rules showing up in roundcube and I sent a test email that was properly put into a sub folder based on one of the rules, I THOUGHT it was working perfectly, but now I realize that the “Send a copy” rules where it should forward to a different email address are not working.
I’ve been reading all the forum messages for the past several hours but I can’t get it working.
What is wrong? I definitely might have not set a permission to a specific folder properly but I can’t figure out where.
I changed the forwarding email address to a different [email protected] and it worked!
So, I think that workaround DID make it kinda work. Although the original forward to email address DID work with a sieve filter on vesta, so I don’t know why it doesn’t work now?
I’m probably way off in terms of the logs you sent, but you could try running /usr/local/hestia/install/upgrade/manual/install_sieve.sh to first uninstall and then reinstall Sieve
To avoid having to remember this every time and to ensure that the process is carried out for all users, I created a script and set it to run via cron every day.
It will create the structure only for those who don’t have it.
I placed this file in:
/code/sieve.sh
#!/bin/bash
# Path to the home directory
home_dir="/home"
# List of users to be ignored
ignore_users=("backup" "admin")
# Function to check if a user should be ignored
should_ignore() {
local user="$1"
for ignore in "${ignore_users[@]}"; do
if [ "$user" == "$ignore" ]; then
return 0
fi
done
return 1
}
# Loop through each directory in /home
for user_dir in "$home_dir"/*; do
if [ -d "$user_dir" ]; then
user=$(basename "$user_dir")
# Check if the user should be ignored
if should_ignore "$user"; then
echo "Ignoring user: $user"
continue
fi
# Check and create if it doesn't exist
if [ ! -f "$user_dir/.dovecot.lda-dupes" ]; then
touch "$user_dir/.dovecot.lda-dupes"
else
echo "File already exists: $user_dir/.dovecot.lda-dupes"
fi
# Check and create if it doesn't exist
if [ ! -d "$user_dir/.dovecot.lda-dupes.locks" ]; then
mkdir "$user_dir/.dovecot.lda-dupes.locks"
else
echo "Directory already exists: $user_dir/.dovecot.lda-dupes.locks"
fi
# Change ownership of the file and directory
chown "$user:$user" "$user_dir/.dovecot.lda-dupes" "$user_dir/.dovecot.lda-dupes.locks"
echo "Configuration completed for user: $user"
fi
done
Thanks @molero.renan !!! this code is perfect. I added it and ran it and it fixed up about 6 new users that I’d completely forgotten about in the last 5 months so thank you very much for the code and for reminding me about this little problem!
If I was more confident, I would add that command to the end of the file that hestiacp runs when creating new users, that way it would run right after a user was added. But I don’t want to break something, so I just set the cronjob to run every 15 mins.