Newsroom Update

Beginning in May, a special Today at Apple series titled “Made for Business” will offer small business owners and entrepreneurs free opportunities to learn how Apple products and services can support their growth and success. Learn more >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Spam learning in ML server?

Hi,

Does anyone know if ML server has the spam learning ability like SL server does where you set up "junk" and "notjunk" accounts to send the appropriate messages to?


Thanks,

Scott

Mac mini, OS X Server

Posted on Nov 10, 2013 10:13 AM

Reply
26 replies

Nov 11, 2013 4:00 PM in response to scottl31

I have been using Spamassasin's learning feature via the terminal app. It does a really good job of filtering out SPAM. To do this, you have to know where your mail directory is, which is harder than it sounds. It will be one of the directories in /Library/Server/Mail/Data/mail/ directory. Once you find the directory, you can either change directory to that directory, or use the full path name with sa-learn. In my case it would be...


sa-learn --spam /Library/Server/Mail/Data/mail/E39E2D15-A43D-4987-BE35-02E4A56470F4/.Junk/


for learning spam.


For learning what is not spam, you can use the same command on your inbox. It will ignore previous messages that it has learned from.


sa-learn --ham /Library/Server/Mail/Data/mail/E39E2D15-A43D-4987-BE35-02E4A56470F4/Cur/


To find the right directory, you can make an odd email box name on the server and list the directories until you see the mailbox name you created.


I had no idea you could send emails to various accounts for learning. I have been using the above message since July and I typically have 2 or 3 messages get through to my email client each week. I use sieve filtering to do server-side filtering of the SPAM messages into the Junk mailbox automatically.


Hope this helps.


-Cameron

Nov 11, 2013 6:43 PM in response to cjmandrake

I found the path that looks like:


sa-learn --spam /Library/Server/Mail/Data/mail/E39E2D15-A43D-4987-BE35-02E4A56470F4/.Junk/


but at that section "E39E2D15-A43D-4987-BE35-02E4A56470F4", I have 21 folder names that look like this but I can't open them. I'm not clear what to do here. If I figure out which one is the "junkmail" account, do I run the above command on it?

Nov 11, 2013 7:50 PM in response to scottl31

You have to use sudo to access the directories. 'sudo ls "directoryname"'.


There is no junkmail account unless you've created one. This instruction was if you were going to just use your own account for spam learning. The reason you can't access the directories is that they are owned by the mailserver processes, which is why you'd need to use sudo to access them.

Nov 11, 2013 9:01 PM in response to scottl31

You would first identify which directory is your personal email box. Then you would use the sa-learn program on the junk mailbox in that directory. Then you can delete the mail in that folder, since it has learned from it what it can.


You have to also use sudo for sa-learn, as well, since you don't own the directories.


Since you are not all that familiar with the unix internals of the OS, you might be better trying to follow the other link. My method does require some experience with the unix command line and understanding directory structures, etc.


-Cameron

Nov 13, 2013 1:28 PM in response to cjmandrake

Although I'm not a command line expert, I'm comfortable with it, especially if I know what to enter or paste in.


When you say to use my "own account for spam learning" or my "personal email box" to run sa-learn on, do you mean that to be the one or ones that need it the most? For example, in the same company, I only get about 30 spams a day, but my boss gets about 500-600.

Nov 13, 2013 2:00 PM in response to scottl31

Each of those directories is a different user's email account and it holds all of their IMAP mailboxes. Since I get the most spam on my system, I just use my own mail account to learn spam. I can get between 300 and 1000 spam messages a day, since I've used the same email address since 1994.


So, you have to find a way to identify who's email directory belongs to whom if you want to use a single account to learn from, or you can run it on all of the .Junk folders. The problem with just using all of them is that a good email can be identified as spam, and you've just taught spamassassin incorrectly. If you knew for sure that each user has checked their junk mailbox for mislabeled mail, then you could just learn from all of them. A shell script could go through each directory and learn from each account, but, like I said, you don't know how well they maintain their junk boxes. I think this is probably why Apple had removed this as an automatic feature, because a couple of good emails marked as spam and further piped into sa-learn might cause a snowball effect of marking emails incorrectly.


If your boss is getting that many spam messages a day, he would be perfect to use learning on. You just have to make sure that he is good about checking for false positives in his junk box. Then you have to figure out which of those directories belongs to him, and run sa-learn on his junk folder. You also should have him empty his junk mail folder after you use sa-learn on it, so the process doesn't take as long each time you run it.


If your users are using Mac Mail, they should have "Trust junk mail headers in messages" checked in the junk mail settings tab, so anything that the mailserver sees as junk is automatically placed in the junk box, whether it would be identified by Mail's own junk filters.


Another thing to consider is that if your users are using POP3 instead of IMAP, all of their junk messages are stored on their local machine instead of the server, so using sa-learn on their mailboxes would not work anyway.


If you can get users to forward spam to a junk account and falsely labeled good messages to a not-junk account, and use the information in this thread...


https://discussions.apple.com/thread/4481820


You'll probably be able to avoid the issues like the ones I mentioned. It just takes a bit of coaxing to get people to do something new.

Nov 13, 2013 3:28 PM in response to cjmandrake

I was getting excited until I realized you were talking about Imap. We are using POP3.


We also have an SL server and we only have a couple mail users on there. I just learned about the "junkmail" and "notjunkmail" account learning feature. That's what made me wonder if it's available on ML.


But on that other thread you gave the link to, it appears that it's only for imap since the command:


sudo serveradmin settings mail:imap | grep junk


mail:imap:junk_mail_userid = "junkmail"

mail:imap:not_junk_mail_userid = "notjunkmail"


and he talks about dumping messages from one box to another, which can't be done in POP3 as far as I know.


Do you know how I can tell if this works for POP3? I can set up the "junkmail" and "notjunkmail" accounts and use them, but I won't know if they are working.

Nov 13, 2013 3:37 PM in response to scottl31

You may be able to forward messages from the pop3 account to the junk email address. So if a user gets an email not already marked as junk, they forward to junkmail@yourdomain.com (the account has to be set up), and the same for messages that are incorrectly marked as junk to notjunkmail@yourdomain.com.


As far as these accounts are concerned, no one would access them with pop, so the email is still in their respective home directories, as the thread I pointed out says. I'm not sure if this method will work with forwarded messages or not, but it'd be worth researching if you really want to improve your spam filtering. I am amazed how well it works for me, but my setup is mostly IMAP. Most of my users are IMAP and webmail, which uses IMAP as well.


The main reasons I keep my email on the server and use IMAP is that my server has 2 TB storage and 2 TB backup, and I can also access via webmail or another computer. The disadvantage is if I don't have a network connection and need to access messages.

Nov 13, 2013 4:00 PM in response to cjmandrake

I had assumed it was done by forwarding by the user to the "junkmail" and "notjunkmail" to make it learn. I guess the user would be accessing them with POP in this case.


Are you saying that a POP3 user forwarding spam to the IMAP "junkmail" and "notjunkmail" accounts will still teach it correctly?


If I run:

sudo serveradmin settings mail:imap | grep junk


I get:

mail:imap:junk_mail_userid = ""

mail:imap:not_junk_mail_userid = ""


Does this mean none of this is enabled on my server?

Nov 15, 2013 10:56 AM in response to cjmandrake

OK, on that other thread it seems as if it's all about IMAP. So I asked a question, but haven't heard anything yet. But you might know, if you don't mind one more question (that I asked over there).


I ran:

sudo serveradmin settings mail | grep junk


I got:

mail:postfix:spam_quarantine = "junk-quarantine@example.com"

mail:postfix:spam_notify_admin_email = "junk-admin@example.com"

mail:postfix:junk_mail_userid = "junkmail"

mail:postfix:not_junk_mail_userid = "notjunkmail"

mail:imap:junk_mail_userid = ""

mail:imap:not_junk_mail_userid = ""


From looking at that, it appears it is set up correctly for user redirects to the "junkmail" and "notjunkmail" accounts, or do I need to do anything else? I sent a bunch of messages to the "junkmail" account yesterday, and they were gone this morning. I'm guessing it's working at 2:15 AM and then deleting all the messages. (I'm using Entourage "online access" view so I can see all messages on the server.)


Also, how do the quarantine and notify admin accounts work? Depending on your answer, if I want to set up accounts for them, how do I change those example.com defaults in the server to the real accounts I set up?


Thanks!

Scott

Nov 15, 2013 11:20 AM in response to scottl31

You should have something in the logs if the junk processes are running. Either mail.log or system.log. If they are disappearing from the accounts, there is a good chance that they are running.


I think the quarantine and notify admin accounts are where push notifications of spam and viruses are sent. I have those turned off, because I was getting far too many notifications for spam and viruses.


To change the settings,

'serveradmin settings mail:postfix:spam_quarantine = "newaddress@yourdomain.com"

'serveradmin settings mail:postfix:virus_quarantine = "newaddress@yourdomain.com"


-Cameron


Spam learning in ML server?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.