Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move spam to spam folder? [closed]

i have already install postfix, dovecot, Clamav, Spamassassin and amavisd-new on my centos 5.10. The tutorial is in here : http://catatanlepas.com/komputer/aplikasi/server-mail/postfix/359-instalasi-postfix-menggunakan-dovecot-di-centos-5-5

I just not install Razor, Pyzor, dan DCC on that tutorial.

Everything is work fine in /var/log/maillog, if there is a spam email n not come to inbox, but i want to move spam email to spam folder.

My Question is : 1. How to auto create spam folder on my webmail because it is just create inbox, draft and sent item only and there is no spam folder on my webmail. 2. How to move spam email to that spam folder per user (i create user on /var/vmail)

Please help me, i have search in google for a 5 days and i am stack on this :(

Thank you.

like image 452
user3747101 Avatar asked Jun 17 '14 04:06

user3747101


People also ask

How do I move my Spam folder?

All you have to do is right-click the email that you want to move and select move to inbox. That will move the email to the inbox and it will tell Windows Mail that you want emails from that sender to go to your inbox in the future instead of to the spam or junk folder.

How do I permanently move my emails to Spam?

The first is through the conversation actions while viewing the message. Hit the More actions button, then Move to Spam. You can also access this through the message list. Select one or more messages that you'd like to move, hit the Move button, then select the Spam folder.


1 Answers

I - Set your email delivery to use Dovecot LDA:

The original website the OP linked is offline, however I believe the email delivery was happening over sendmail program, which it should be done over Dovecot LDA for what you need. (To avoid email origin header changes).

Edit Postfix's master.cf (at the beginning):

smtp      inet  n       -       -       -       -       smtpd -o content_filter=spamassassin

And at the end of the file:

spamassassin unix -     n   n   -   -   pipe
    flags=DROhu user=vmail:vmail argv=/usr/bin/spamc -f -e 
    /usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop} 

Now edit Postfix's main.cf and add (optional, check (3) bellow):

spamassassin_destination_recipient_limit = 1

Now your email will be delivered via Dovecot LDA without header changes. For the curious ones, here are some details on my config:

  1. This config can be used with plus-addressing / sub-addressing / recipient delimiters (emails addressed to [email protected] will be delivered into [email protected] inbox) - That's why I added -d ${user}@${nexthop} this will remove the + and everything until the domain. To enable this feature, also be sure to add recipient_delimiter = + into main.cf;
  2. My flags flags=DROhu, they don't add anything abnormal but they can be understood here: http://www.postfix.org/pipe.8.html;
  3. spamassassin_destination_recipient_limit = 1 is required to make sure that every recipient gets individually processed by spamassassin. This is required due due to the D flag above (Includes X-Original-To header). If you don't care about this header you can remove the flag and this isn't needed.

II - Move your SPAM to the Junk folder:

(With some help from @Electronic Technologies at https://stackoverflow.com/a/32470349/560745)

You can also configure Dovecot to move email detected as SPAM to the Junk IMAP folder. Just follow this:

  1. Edit /etc/dovecot/conf.d/15-mailboxes.conf and uncomment / add the Junk folder with (should be on the namespace inbox section near mailbox Trash):

    mailbox Junk {
       special_use = \Junk
    }
    
  2. Install dovecot-sieve with apt-get install dovecot-sieve;

  3. Edit /etc/dovecot/conf.d/90-sieve.conf and comment the line: #sieve = ~/.dovecot.sieve

  4. Edit /etc/dovecot/conf.d/90-plugin.conf as:

    plugin {
        sieve = /etc/dovecot/sieve/default.sieve
    }
    
  5. Edit /etc/dovecot/conf.d/15-lda.conf and /etc/dovecot/conf.d/20-lmtp.conf to match:

    protocol lda/lmtp { # do not copy/paste this line!
      mail_plugins = $mail_plugins sieve
    }
    

    WARNING: You might have another settings under the protocol selections, keep them. The line protocol lda/lmtp changes in the files, keep the original.

  6. Create folder /etc/dovecot/sieve/

  7. Create file /etc/dovecot/sieve/default.sieve with this content:

    require "fileinto";
    if header :contains "X-Spam-Flag" "YES" {
        fileinto "Junk";
    }
    
  8. Change folder permissions to your virtual email user and group like: chown vmail:vmail /etc/dovecot/sieve/ -R. If you miss this dovecot will complain!

  9. Restart everything: service postfix restart; service dovecot restart; service spamassassin restart

  10. Try to send an email to some email on the server (from an external server), first a normal email and then another one with this subject: XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X. The second email should to into the Junk folder and the first to your inbox.

If this doesn't work at your first try, look at the logs: tail -f /var/log/mail.log and send the email while tail is running. A good working setup should report stored mail into mailbox 'INBOX' or stored mail into mailbox 'Junk'.

like image 157
TCB13 Avatar answered Oct 07 '22 23:10

TCB13