Howto Install Courier-MTA on Linux Debian
Introduction
For several years now that I come from mail servers installed on any distribution of Linux, but I have to always be looking for the network tips to refresh your memory. And now casually for work and I need to do a howto, then it is time to seize the opportunity.
Requirements
Packages
Repositories
Before you throw down to work, it's a good idea to verify that the configuration of our APT Debian repositories containing contrib non-free.
deathbian: ~ # vim / etc / apt / sources.list
deb http://ftp.debian.org/debian/ etch main contrib non-free deb-src http://ftp.debian.org/debian/ etch main contrib non-free deb http://security.debian.org/ etch / updates main contrib non-free deb-src http://security.debian.org/ etch / updates main contrib non-free
Courier installation base
To put our mail server in place it is necessary to install these packages
- Courier
- Spamassassin
- Clamcour
as follows;
deathbian: ~ # apt-get install courier-mta deathbian: ~ # apt-get install courier-imap deathbian: ~ # apt-get install courier-imap-ssl deathbian: ~ # apt-get install courier-maildrop deathbian: ~ # apt-get install spamassassin deathbian: ~ # apt-get install clamcour
Configuration files
ClamAV
When you install the packages of our clam antivirus automatically configures the Debian Linux, (found here tunear parameters for the installation). However, because we want our mail service can vaccinate the contents before reaching the boxes of users, we must create the file / usr / bin / clamscan.sh, with the following contents
| file: / usr / bin / clamscan.sh |
#! / bin / bash # Created by Tom Walsh, slim at ala.net # Slightly modified by Wolfgang Ziegler, nuppla at gmx.at RUN = clamscan # Enable this line, if you are using the clamav-daemon. RUN # = clamdscan # start MSG = $ (</ proc/self/fd/0) # stdin -> $ MSG SCAN = $ (echo "$ MSG" | $ RUN - - stdout - disable-summary) EXIT ="$?" VIRUS = $ (echo "$ SCAN" | awk '(print $ 2)') SUBJECT = $ (echo "$ MSG" | x-reformail Subject:) if [ "$ EXIT" == "1"]; then SUBJECT = "VIRUS ** ** [$ VIRUS] $ SUBJECT" MSG = $ (echo "$ MSG" | reformail-i "X-Virus-Status: INFECTED") MSG = $ (echo "$ MSG" | reformail-i "Subject: $ (echo" $ SUBJECT ")") else MSG = $ (echo "$ MSG" | reformail-i "X-Virus-Status: CLEAN") fi echo "$ MSG" exit 0 |
Do not forget to return the executable file ...
chmod + x / usr / bin / clamscan.sh
SpamAssassin
To make the configuration of SpamAssassin, we run the perl shell, with the following command:
perl-MCPAN-e shell
and within the shell, type:
install Mail:: SpamAssassin
and optionally
install Mail:: SPF:: Query
install IP:: Country:: Fast
If the interface installation asks them if they want to run tests Razor2 or DCC, just press Enter to select NO. Upon completion keys q and press enter to finish.
Now edit / etc / mail / spamassassin / local.cf as follows:
| file: / etc / mail address / spamassassin / local.cf |
# # Created by Luis Fernando Gramajo, fher98 at guatewireless.net V.1.0 # report_safe 0 trusted_networks 10.0.1/24 # The networks on which we rely required_hits 6.0 # Punctuation required for a mailing to be cataloged as spam whitelist_from guatewireless.net # * @ domain in which we trust and we do not expect spam use_bayes 1 bayes_path / var / lib / spamassassin / Bayes # The directory / var / lib / spamassassin will be necessary to create it auto_whitelist_path / var / lib / spamassassin / auto-whitelist bayes_auto_learn_threshold_nonspam -0.1 skip_rbl_checks 0 use_razor2 1 razor_config / etc / razor / razor-agent.conf use_dcc 1 use_pyzor 0 pyzor_options - homed / etc / Pyzor # Only if it is necessary to change use_pyzor 1 dns_available yes LOCAL_RCVD Received header = ~ / .* \ (\ S + \. domain \. com \ s + \ [.* \] \) / describes LOCAL_RCVD Received from local machine -50 score LOCAL_RCVD # # Increases punctuation - optional score DCC_CHECK 2500 # A good value is between 2,500 and 4,000, but it depends on the domain SPF_FAIL score 10,000 SPF_HELO_FAIL score 10,000 score RAZOR2_CHECK 2500 score BAYES_99 4300 score BAYES_95 3500 score BAYES_80 3000 # # Reduction of punctuation - optional, but very useful DK_SIGNED score -1000 DK_VERIFIED score -2500 score SPF_PASS -2500 |
In this version of spamassassin have to edit the file / etc/mail/spamassassin/v310.pre, and remove the # of the two lines below
# DCC - DCC message perform checks. # # DCC is disabled here because it is not open source. See the DCC # License for more details. # loadplugin Mail:: SpamAssassin:: Plugin:: DCC # Razor2 - perform Razor2 message checks. # # Razor2 is disabled here because it is not available for unlimited free # Use. It is currently free for personal use, subject to capacity # Constraints. See the Cloudmark SpamNet Service Policy for more details. # loadplugin Mail:: SpamAssassin:: Plugin:: Razor2
Set of Rules
Look at the site of [Custom Rulesets page] to find a set of special rules to install on your system. To install a rulset, simply copy the directory / etc / mail / spamassassin.
Check the configuration
It is important to be sure that the configuration of SpamAssassin is correct. When finished, type
spamassassin - debug - Lint
Which we displays a list of the configuration information that tells us if there is some sort of error. There are a lot of info on this list. Delen a review in each line of the list to see if everything is in order.
Maildrop
Maildrop is a native of Courier, designed to perform advanced filtering tasks. For the moment let's just set courier to deliver the mail through maildrop.
To be able to filter mail through maildrop edit the file / etc / courier / courierd, we seek and will exchange it for DEFAULTDELIVERY
| file: / etc / courier / courierd |
DEFAULTDELIVERY = "| / usr / bin / maildrop"
|
Filtering with SpamAssassin and ClamAV
This is the general maildrop file for the entire system. What I write here will affect all incoming mails from users, and it is for this reason, that within this file write the script in order to filter out viruses / spam with SpamAssassin and ClamAV.
| file: / etc / courier / courierd |
# / etc / courier / maildroprc # ClamAV local Courier-scan # By Luis Fernando Gramajo P. 23/11/06 # fher98 at gmail DOT com Our # shell SHELL = "/ bin / bash" # The path by default DEFAULT = "$ HOME / Maildir" # Taking the name of the user # import USER # The logfile logfile "/ var / log / maildrop" # Verbosity of the log VERBOSE = "5" # Only verified with anti-mails under VSCANSIZE VSCANSIZE = "20000000" "The mails pass through the layers of antispam filters, if only with minor SCANSPAMSIZE SCANSPAMSIZE = "20000000" ################################################## ############################# # # Making use of ClamAV to eliminate the virus. # ################################################## ############################# if ($ SIZE <$ VSCANSIZE) ( Exception ( xfilter "/ usr / bin / clamscan.sh" ) ) if (/ ^ X-Virus-Status: .* infected) ( `test-d $ DEFAULT / .Quarantine` if ($ RETURNCODE == 1) ( `/ usr / bin / maildirmake-f $ DEFAULT` Quarantine `echo INBOX.Quarantine>> $ DEFAULT / courierimapsubscribed` ) Exception ( # to "$ DEFAULT / .Quarantine /" to "/ dev / null" ) ) # This is added on each record in the logs. # Just a simple visual aid. log "------------------------------------------------ - " ################################################## ############################# # # Making use of SpamAssassin to eliminate spam. # ################################################## ############################# if ($ SIZE <$ SCANSPAMSIZE) ( xfilter "/ usr / bin / spamc-u-s $ USER $ SCANSPAMSIZE" ) if (/ ^ X-Spam-Flag: YES /: h | | / ^ X-Spam-Status: Yes /: h) ( # This creates the directory for spam `test-d $ DEFAULT / .Spam` if ($ RETURNCODE == 1) ( `/ usr / bin / maildirmake Spam-f $ DEFAULT` `echo INBOX.Spam>> $ DEFAULT / courierimapsubscribed` ) Exception ( to "$ DEFAULT / .Spam /" ) ) |
Courier
The Courier's configuration files are kept in / etc / courier
/ etc / courier / courierd
- The default configuration uses the mbox format and no. / Maildir. Previously we made the change to be delivered via maildrop.
| file: / etc / courier / courierd |
################################################## ###################### # # # NAME: DEFAULTDELIVERY: 0 # # Specify default delivery instructions by setting DEFAULTDELIVERY # One of the following definitions of DEFAULTDELIVERY should be # Uncomment. Now the mails are delivered within. / Maildir, via maildrop DEFAULTDELIVERY = "| / usr / bin / maildrop" |
/ etc / courier / esmtpd
| file: / etc / courier / esmtpd |
BOFHCHECKDNS = 1 BOFHNOEXPN = 1 BOFHNOVRFY = 1 ESMTPAUTH = "LOGIN" BLACKLISTS = "= relays.ordb.org-block, BLOCK = sbl-block-xbl.spamhaus.org, BLOCK-block = bl.spamcop.net, BLOCK " |
/ etc / courier / esmtphelo
- Aca type the FQDN of our mail server. Most mail servers do not accept the post if FQDN of the sender is not properly registered.
echo "host.dominio.tld"> / etc / courier / esmtphelo
/ etc / courier / me
- In this file also must enter the FQDN of our mail server (also may be the name of the local machine).
echo "host.dominio.tld"> / etc / courier / me
/ etc / courier / aliaes / dominio.tld
- fher98 is a local user's system.
| file: / etc / courier / aliaes / dominio.tld |
usuario@dominio.tld: fher98
|
/ etc / courier / esmtpacceptmailfor.dir / dominio.tld
| file: / etc / courier / esmtpacceptmailfor.dir / dominio.tld |
dominio.tld |
/ etc / courier / hosteddomains / domain.tld
| file: / etc / courier / hosteddomains / domain.tld |
dominio.tld
host.dominio.tld <tab> dominio.tld
|
/ etc / courier / bofh
| file: / etc / courier / bofh |
BOFHSPFMAILFROM opt = none, pass, neutral, unknown BOFHSPFFROM opt = mailfromok, all BOFHSPFTRUSTME opt = 1 opt = accept BOFHBADMIME BOFHCHECKHELO opt = 0 |
Start Services
Courier MTA
- Here we lift the services of the Courier.
deathbian: ~ # / etc / init.d / courier-mta restart deathbian: ~ # / etc / init.d / courier-imap restart deathbian: ~ # / etc / init.d / courier-authdaemon restart
The filtering system Antivirus / AntiSpam
- As easy as:
deathbian: ~ # / etc / init.d / spamd start deathbian: ~ # / etc / init.d / clamd start deathbian: ~ # / etc / init.d / courier restart deathbian: ~ # filterctl start clamcour
Please check the blog (log) in the email to see the activation clamcour.
Popularity: 15% [?]
3 comments to "Howto Install Courier-MTA on Linux Debian"
Trackback URI | Comments RSS







on 18 Dec 2007 at 3:05 pm # Cristhian
Hello this very interesting and complete your article, but I left a problem when running the debugging spamassassing.
[1343] warn: config: warning: Sept. score for non-existent rule DK_SIGNED
[1343] warn: config: warning: Sept. score for non-existent rule DK_VERIFIED
q you the truth and given its good laps and still not see it as the fix that
If I could give a help to you in advance agradesco
Greetings
[Reply]
fher98 responded on December 18th, 2007:
Cristhian:
As you've read in the article, you install several plugins to spamassassin to eliminate spam, that sounds to me that something was missing.
# DomainKeys
ifplugin Mail:: SpamAssassin:: Plugin:: DomainKeys
DK_POLICY_SIGNALL score 0.001
DK_POLICY_SIGNSOME score 0.001
DK_POLICY_TESTING score 0.001
DK_SIGNED score 0.001
DK_VERIFIED score -0001
# endif Mail:: SpamAssassin:: Plugin:: DomainKeys
Keys these commands?
perl-MCPAN-e shell
and within the shell, type:
install Mail:: SpamAssassin
install Mail:: SPF:: Query
install IP:: Country:: Fast
Well, give us all, and thank you for your inquiry, ... .. Greetings!
[Reply]
on 28 Mar 2008 at 6:11 pm # Carlos
Actually I have all these facts right but showed me the following message:
[6467] DBG: config: warning: Sept. score for non-existent rule DK_POLICY_SIGNSOME 0.26408
[6467] DBG: config: warning: Sept. score for non-existent rule DK_SIGNED 0.00046
[6467] DBG: config: warning: Sept. score for non-existent rule DK_POLICY_SIGNALL 0.00064
[6467] DBG: config: warning: Sept. score for non-existent rule DK_VERIFIED 0.00246
[6467] DBG: config: warning: Sept. score for non-existent rule DK_POLICY_TESTING 0.0012
And I like to check whether the DomainKeys is running.
Thank you
[Reply]