Technology
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Host By : Shwe Yaung Myanmar
 
HomeAdvertisingSearchLatest imagesRegisterLog inAdvertising Space

 

 Linux Mail Server Part 4

Go down 
AuthorMessage
Admin
Admin



Posts : 49
Join date : 2008-01-09

Linux Mail Server Part 4 Empty
PostSubject: Linux Mail Server Part 4   Linux Mail Server Part 4 EmptyFri Jun 20, 2008 6:29 am

# Move to mailboxes quickly
macro index <Esc>1 "c~/Maildir\r"
macro pager <Esc>1 "c~/Maildir\r"
macro index <Esc>2 "c~/Maildir/.CaughtSpam\r"
macro pager <Esc>2 "c~/Maildir/.CaughtSpam\r"
macro index <Esc>3 "c~/Maildir/.Unsure\r"
macro pager <Esc>3 "c~/Maildir/.Unsure\r"
macro index <Esc>4 "c~/Maildir/.Tur\r"
macro pager <Esc>4 "c~/Maildir/.Tur\r"
macro index <Esc>5 "c~/Maildir/.Sbayes\r"
macro pager <Esc>5 "c~/Maildir/.Sbayes\r"
macro index <Esc>6 "c~/Maildir/.Wikka\r"
macro pager <Esc>6 "c~/Maildir/.Wikka\r"
# Training Maildirs for Spam and Ham
macro index <Esc>8 "c~/Maildir/.MissedSpam\r"
macro pager <Esc>8 "c~/Maildir/.MissedSpam\r"
macro index <Esc>9 "c~/Maildir/.MissedHam\r"
macro pager <Esc>9 "c~/Maildir/.MissedHam\r"
# Job E-mails
macro index <Esc>0 "c~/Maildir/.Job\r"
macro pager <Esc>0 "c~/Maildir/.Job\r"

# Setting these colors makes it easy to tell which emails
# Spambayes has missed.
# Turn spam red and unsure green
color index red default "~h '^X-Spambayes-Classification: spam'"
color index green default "~h '^X-Spambayes-Classification: unsure'"
# Turn gmail mail brightblue
# (My regular expression is not correct here. I think that it
# is looking anywhere in the header for my gmail address
# instead of what I wanted.. Just in the 'To:'.
# It still works for the most part)
color index brightblue default "~h '(^)*my_name@gmail.com'

# Lets set more colors to make things look beautiful. Judging by
# my title for this section I must have had bad feelings towards
# colors when I added this.
#Color crap
color index brightwhite default ~N # color for new messages
color status black yellow
color attachment brightyellow default # file attachments
color search brightred default # search matches
color quoted brightyellow default # quoted text in replies
color quoted1 magenta default # quoted text in replies
color body cyan default "((ftp|http|https)://|news:)[^ >)\"\t]+" # URLs
color body cyan default "[-a-z_0-9.+]+@[-a-z_0-9.]+" # email

# The rest of this stuff is pretty important for functionality and
# readability.

# Don't ask to move read message
set move=no

# My signature is in this file
set signature="~/.signature"

# Change mail to look like from scott@hypexr.org
# Stick your email address here.
my_hdr From: Scott Rippee <scott@hypexr.org>

# Header control h displays header when in pager
# I want to only see the unignored by default
ignore * # weed out all headers
unignored date from: to cc subject organization # now show me these...

# Thanks to many people whom have written the documents and posts that I
# have gotten these settings from.

New Mutt Commands

Here are the most useful (as far as dealing with spam) commands that we can now use in mutt:

t Tag messages to be manipulated
S Send message/s to spam training folder
H Send message/s to ham training folder and to inbox
alt-1 Change mailbox to Maildir/ (inbox)
alt-2 Change mailbox to .CaughtSpam
alt-3 Change mailbox to .Unsure
alt-8 Change mailbox to .MissedSpam
alt-9 Change mailbox to .MissedHam

So for example, if a couple of spam messages show up in your inbox you can now tag them and hit 'S' (remember its uppercase s) and have them vanished into .MissedSpam for training.


SquirrelMail Configuration

To configure SquirrelMail go into your html_base_directory/squirrelmail/config and run ./conf.pl. Edit the options to fit your needs. If you want to test your config cruise over to http://localhost/squirrelmail/src/configtest.php.

Now go to http://localhost/squirrelmail/ and login using your user account. If you have any email in your in box you should see it after you log in. Now click on the Folders option that is along the top, select all of the mailbox folders that we created earlier (they are listed here because we prefixed them with a period), and click on subscribe. Hit refresh and the mailboxes should be listed in the side panel. Now you can use SquirrelMail for almost all of you mail needs including tagging messages and moving them to the correct folders for Spambayes training and checking on the mail that Spambayes has classified as spam and unsure. The only functionality from our mutt setup that can't be duplicated in SquirrelMail is copying missed ham into its training folder and then moving it into your inbox. This is due to the lack of copying ability. So you will have to go into the ham training folder to see some of the mail that should be in your inbox.

!!! IMPORTANT SECURITY NOTE!!! - Using SquirrelMail like this is not secure! Sending the plain text passwords that you use for your Unix account can be accessed by by a 3rd party, which would them access to your account. You should set up a secure server with SSL and have Courier-imap use passwords that differ from the users system password using Courier Authlib, which I will demonstrate in the next session. Excellent documents exist all over the net for setting up your web server with ssl.

Linux Mail Server Part 4 Sqmss_tn

Courier Authentication

Now is a good time to address a bit of essential security. As of now when a user connects via the SquirrelMail or IMAP interface the passwords are being sent in plain text and if these are sniffed that users system account is compromised. Without adding secure connections we can minimize the threat by using alternate passwords for imap connections. The snoop would then have access to your mail, but not be able to log in to the system.

Edit your authdaemonrc file. If your on Arch Linux this will be in /etc/authlib. Under authmodulelist I commented out:

authmodulelist="authpam authpwd authuserdb authshadow ..."

And replaced it with:

authmodulelist="authuserdb"

I believe that adding authuserdb to the front of the list may work, but I am only using this method of authentication so it is all I need in my list.

Lets create the user account entry:

$ userdb "some_user_name" set home=/home/user_dir \
mail=/home/user_dir/Maildir \
uid=users_userid gid=users_groupid

$ userdbpw | userdb "some_user_name" set systempw

You will now be prompted for this pseudo users new password. Next make sure that /etc/authlib/userdb has read/write/execute access for the owner. If not chmod 700 /usr/authlib/userdb. Now create the user database that courier is going to look to for authentication:

$ makeuserdb

Again look to using Postfix/TLS for a tunneling the connection through a secure connection.

Pop-before-smtp Configuration

To successfully configure pop-before-smtp follow the straight forward instructions in contrib/README.QUICKINSTALL. When you are done and everything is working it is important to make sure that you have not some how made your mail server an open relay! This would cause your mail server to be flooded with traffic and be put on the open relay ban lists.

!!! IMPORTANT SECURITY NOTE!!! - I will not use the pop-before-smtp method because it involves sending a password over an insecure connection. Use Postfix through a SSL connection, Postfix/TLS, to accomplish this. Since your local machines are likely already allowed to use your Postfix as a mail relay the only time that you would be using this method is from a non-trusted server where you password can be sniffed. If you still choose to use this method make sure that you have changed the users courier password as described in Courier Authentication.

Additional Simple Procmail Recipes and Mailbox Config

If you are a member of any news letters/mailing lists you can have them automatically sorted to their own mailbox using Procmail. First create the new mail directory in your ~/Maildir directory. Lets call it .Sbayes and pretend that we are on the Spambayes mailing list. So exactly as before with the spam related mailboxes:

mkdir -p ~/Maildir/.Sbayes/{cur,new,tmp}

Now add this new rule to your ~/.procmailrc:

# spambayes-dev@python.org mailing list
:0
* ^X-BeenThere: spambayes@python.org
${MAILDIR}/.Sbayes/

In the .mutrc example above it shows an example of setting alt-5 as the macro to see your Spambayes emails.

A slightly different method can be used to send spam and ham for training. Adding the following lines will allow you to bounce spam messages to spam@localhost (localhost or your mail_domain.com) and ham messages to ham@localhost:

# Mail has been bounced to spam@localhost
:0
* ^Resent-To:.*spam
${MAILDIR}/.MissedSpam

# Mail has been bounced to ham@localhost
:0
* ^Resent-To:.*ham
${MAILDIR}/.MissedHam

If you want to bounce messages to the spam and ham addresses like this, you will need to make sure that the headers stay intact. Do not try using this or a similar technique for forwarding mails to an address because the email's headers would not be intact and this is a large part of the spam classification. This method works because above we specified spam and ham as aliases for hypexr in the Postfix aliases file.

Conclusion

For Arch Linux users, Add saslauthd authdaemond courier-imap postfix fetchmail to DAEMONS in your /etc/rc.conf file and they will be started automatically when your machine boots. If you are running a web server have the httpd service listed after the services we are adding.

/etc/rc.conf

DAEMONS=(... saslauthd authdaemond postfix courier-imap fetchmail ...)

Enjoy your new mail system and centralized mailbox. If you are handling a large number of users for you email system this is just the tip of the iceberg and you are going to mostly be interested in virtual users, security, and a system wide spam classifier. There are many good documents on various setups to accomplish this, see the links section. If you have any suggestions, questions, comments, or corrections send me an email or drop a note in the forum. If this document has been of any use to you, cheers. Smile

Resources

Example Files
o .fetchmailrc
o .procmailrc
o .muttrc
o train_spambayes
Links
o Arch Linux
o Postfix
o Procmail
o Fetchmail
o SpamBayes
o Mutt
o SquirrelMail
o Courier-imap
o Courier-authlib

Virtual users and mailboxes using MySQL and setting up SSL for SquirrelMail
o Arch Wiki - Postfix Howto
o Gentoo - Virtual Mailhosting System with Postfix Guide

Other Useful links
o Arch Linux Postfix HowTo
o Jkx@Home's Courier Authentication
o Postfix with TLS and SASL - geared towards FreeBSD
o Setting up Postfix + MySQL + Courier-IMAP + Mailman + vmail + Procmail + SpamAssassin - geared towards Fedora/Red Hat
o Postfix Howtos and FAQs
o The Mutt E-Mail Client Manual
o Timo's procmail tips and recipes
Back to top Go down
https://shweyaungmyanmar.board-directory.net
 
Linux Mail Server Part 4
Back to top 
Page 1 of 1
 Similar topics
-
» Linux Mail Server Part 1
» Linux Mail Server Part 2
» Linux Mail Server Part 3
» Configure Apache Web Server == Part 1 ==

Permissions in this forum:You cannot reply to topics in this forum
Technology :: Networking Zone :: Linux Networking-
Jump to: