Re: Forwarding mail addresses
Posted: Mon Apr 06, 2015 2:13 pm
Aight people listen up. I think I found the cause of the issue why "Do not store forwarded email" isn't working properly.
If we check the fwd_only file in in $HOMEDIR/$user/conf/mail/$domain/fwd_only, we see it only holds 1 entry max. If we add another forward only account in the GUI, we see that LAST entry. Now after some debugging, I found out that if you add or edit something in the GUI, the following command is called:
v-add-mail-account-fwd-only USER DOMAIN ACCOUNT
Now if we open this file in /usr/local/vesta/bin/v-add-mail-account-fwd-only we see the following line somewhere near the end:
$account" > $HOMEDIR/$user/conf/mail/$domain/fwd_only
Aha! It overwrites the file instead of appending the new account. All we need to do is change > to >>. We can do this with the following command:
sed -i 's/echo "$account" > $HOMEDIR\/$user\/conf\/mail\/$domain\/fwd_only/echo "$account" >> $HOMEDIR\/$user\/conf\/mail\/$domain\/fwd_only/g' /usr/local/vesta/bin/v-add-mail-account-fwd-only
Eh voila, email forwarding only fixed (at least for me). Try it out and see if it works. And I hope the developers can change this in the real code :)
P.S.: This might be why it seemed to work for some people who only test with 1 account (cause yeah, it works for one account, just not multiple :) )
If we check the fwd_only file in in $HOMEDIR/$user/conf/mail/$domain/fwd_only, we see it only holds 1 entry max. If we add another forward only account in the GUI, we see that LAST entry. Now after some debugging, I found out that if you add or edit something in the GUI, the following command is called:
v-add-mail-account-fwd-only USER DOMAIN ACCOUNT
Now if we open this file in /usr/local/vesta/bin/v-add-mail-account-fwd-only we see the following line somewhere near the end:
$account" > $HOMEDIR/$user/conf/mail/$domain/fwd_only
Aha! It overwrites the file instead of appending the new account. All we need to do is change > to >>. We can do this with the following command:
sed -i 's/echo "$account" > $HOMEDIR\/$user\/conf\/mail\/$domain\/fwd_only/echo "$account" >> $HOMEDIR\/$user\/conf\/mail\/$domain\/fwd_only/g' /usr/local/vesta/bin/v-add-mail-account-fwd-only
Eh voila, email forwarding only fixed (at least for me). Try it out and see if it works. And I hope the developers can change this in the real code :)
P.S.: This might be why it seemed to work for some people who only test with 1 account (cause yeah, it works for one account, just not multiple :) )