Hello,
So I just got a mail server up and running. It's a server running Debian, Postfix, Dovecot and Spamassassin.
I noticed that Dovecot was putting all my "extra" IMAP folders in /home/user/mail/ and I thought this would be a nice place to put all mail, since Postfix was dumping them into /var/mail/user.
The problem is that I can get Dovecot to switch over because it has a configuration item like:
mail_location = /home/%u/mail/
However, it appears that Postfix doesn't allow for variables such as %u (username), so I'm frankly at a loss as to how I can redirect incoming mails to /home/username/mail/inbox. I tried a google search, and one person recommended changing the environment variables for MAIL to MAIL=/home/username/mail/inbox. Didn't seem to work tho. Maybe I did something wrong, I dunno. Either way, doing this for a few users might not be too horrible, but there's got to be a cleaner way.
Can anyone help me out here?
Also, Spamassassin is great and all, but it doesn't make any damn sense to have a spam filter that highlights the spam and puts it in my inboxes anyway. Is there any way to get those spam mails sent to /home/user/mail/Spam instead?
Posts
Look at procmail and write some rules that filter it based on the headers Spamassassin injects.
Spamassassin just flags stuff as spam/ham; any filtering will have to be done further down the chain.
True, I want to have the server primarily IMAP based, but I was kind of thrown off by the fact that my mail folders were pretty much strewn about the file system instead of all in a neat and orderly directory structure such as /home/username/mail
It would just be easier for me to deal with if everything was organized. I had read about procmail, I think I'll give that a shot.
I also just installed amavisd-new. From what I understand, amavisd is a sort of broker between the MTA and filters, so it would be easier and more efficient to hook everything into amavisd instead of trying to get everything wormed into postfix, right?
Edit:
actually it looks like someone did try and use my shit as a relay:
I should be in the clear, right?
As to moving where mail is stored, I believe you just need to add the following line to your /etc/postfix/main.cf:
mail_home = mail
The mail_home directive will change the mail file to whatever you put there relative to the user's $HOME. I'm not 100% certain this will do what you need as I always use a qmail style Maildir/ setup, but I think this will work.
home_mailbox = mail/inbox
that way all mail is being appended to the file inbox which is located in /home/username/mail. Yay, it's organized!
I also had to reconfigure dovecot to get mail out of this file, which threw me off for a second, because I saw that postfix was doing the right thing. Maybe I should stop consuming alcohol when playing around with my mail server
But yeah, that looks right. I wasn't sure if /home/<user>/mail was a dir or the actual file. Like I said, I haven't run it like that in a long time.
Anyway, glad it's working for you. Now when are you going to get to the fun stuff and enable tls/ssl for it? Thats actually nice and easy with Debian. Back when I first did it on Slackware you had to download the postfix source and a couple of third party patches.
As to spamassassin, yes, there is a way to do what you want. I had that set up on an old server although I don't bother with it now. I believe I had to fiddle about with procmail to get it to do that. I'll dig to see if I've still got the old config files backed up somewhere.
Actually, something along the lines of this is probably what you need. http://wiki.apache.org/spamassassin/UsedViaProcmail
I just installed the amavisd, spamassassin, clamav trifecta and it seems to be working very well. Just gotta get the spamassassin mails to move into the Junk Email file automatically and I'll be good to go. I did happen to notice that procmail (at least as far as it's described in online blog posts) wants to deposit mails (perhaps as individual files) in a folder, instead of appending them to a text file like my current setup. Is this so, or can this be changed around?
I'm not quite sure how I stand on that issue. On the one hand, just having 5 or so big files makes backups a lot easier, but on the other hand, it makes finding individual emails a bitch.
I'll have to take a look at all that tomorrow... bed's calling!
which seemed to stop it from outright deleting spam, but when passed along to Maildrop (installed it last night), it doesn't seem to react to the X-Spam: Yes field like it should:
Maybe I actually need to name it .Spam instead of .Junk\ E-mail... lord only knows if that even works...
TL;DR, this is a config I downloaded and modified only slightly. It sets some variables, checks for the Maildir and .Junk folders and then checks if the mail is marked X-Spam-Flag: YES, and if so, move to Maildir/.Junk.
I tried it on my test account, but it kept sending the mails into my regular inbox. It was failing the Maildir and .Junk folder checks, which was weird, because the Maildir was there, so I manually created the /home/testuser/Maildir/.Junk. Suddenly, every time I passed a spam mail it came into the Junk mail folder, just like it should. If I look at the log, Maildrop says the Maildir and .Junk folder tests now pass, even though I only added the .Junk folder. I've tried different permutations of the Maildir variable (with and without trailing slash, etc..), but it still fails if .Junk isn't there in my regular "live" account. Directory permissions are the same in both cases (user:user, drwx
).
So that's problem one. Problem two is that even though I have:
in /etc/postfix/master.cf, it's still somehow not being called properly and emails that go to my test account seem to bypass maildrop entirely and get dropped straight into my inboxes anyways.
Got any tips?
to /etc/postfix/main.cf and give postfix a good reload. After that, it was properly filtering mails through maildrop. The automatic creation of folders via Maildrop doesn't work for some reason, but I added the folders to /etc/skel, so any future users should have the appropriate folders to start out with, so it's probably not that big of a deal.