Update template filter_userspamfolder not to save to spambox if account doesn't exist

Version 1.4

Bugfix
Finished

When the option: "Send the spam to the appropriate users's spam folder." is used with SpamAssassin, any spam will be saved to the spambox, eg: /home/username/imap/$domain/$local_part/Maildir/.INBOX.spam/new However, if spam is sent to a forwarder, where no local mailbox exists, the filter will create that path to save it to the spambox, when it shouldn't. The fix was to add extra code to the filter template: /usr/local/directadmin/data/templates/filter_userspamfolder where it will check for the account to exist, and if not, it will save the spam to the system account's spambox. Changed: save |HOME|/imap/$domain/$local_part/Maildir/.INBOX.spam/new/ 660 to be: if "${if exists{|HOME|/imap/${domain}/${local_part}}{yes}{no}}" is "yes" then save |HOME|/imap/$domain/$local_part/Maildir/.INBOX.spam/new/ 660 else save |HOME|/Maildir/.INBOX.spam/new/ 660 endif Note, if the catch-all is enabled (which I never recommend), the system account's spambox will grow quite rapidly. Apart from not enabling catch-all accounts, I recommend to enable the spambox purge option in the Admin Settings. Figuring out the syntax for the "exists" check took a while, as it uses double "if's" for string expansion to convert to a yes/no, then a string test for "yes" on that result. Somewhat obfuscated, but that's why exim is so powerful. To force a rewrite of all filter files, use this, as the filter files won't be rewritten with the update, but only after a User saves a change: http://www.directadmin.com/features.php?id=660 Also create a new template file: /usr/local/directadmin/data/templates/filter_filterspamfolder for when a basic "spam filter" (word filter) is used to redirect to the spambox. The same rules apply, where the new double-if is used to ensure the folder exists. If not, it's saved in the main spambox. -------------------- Related to the issue: (bottom part about not scanning forwarders) http://help.directadmin.com/item.php?id=156 however, it wasn't a good solution because spam would then be forwarded to external systems (eg: gmail) without being scanned. This could potentially cause your server to be blacklisted for sending spam, when it was only forwarding it. The above fix is good because it allows forwarders to still be scanned, but doesn't save the local copy.

Interested to try DirectAdmin? Get a 30-day Free Trial!