CentOS Icon CentOS Logo
CentOS Text
   
  
www.centos.org Forum Index
   CentOS 4 - Server Support
  HOWTO: Pretty much bulletproof (and spam-proof) email...

 

 Bottom   Previous Topic   Next Topic
  •  Rate Thread
      Rate this Thread
      Excellent
      Good
      Average
      Bad
      Terrible
Poster Thread Rated:  7 Votes
  •  wizard
      wizard
HOWTO: Pretty much bulletproof (and spam-proof) email...
#1
Peeking in the Member Window
Joined: 2006/8/15
From surreal city, usa
Posts: 25
Don't know if HOWTOs are allowed here, but I thought I'd share in case anyone else is having issues setting up a reasonably bulletproof mail setup - mods can feel free to delete this if I've crossed a line - but I've migrated a lot of the stuff I've learned from the Fedora project here and wrote a simple guide on getting mail working -

We've added a virus scanner, spam control, greylisting and three DNS blacklists to sendmail's configuration. This stuff ought to reduce your spam by about 90%. The only one that's not self-explanatory is milter-greylist. Greylisting temporarily rejects email, assuming that real mail servers will resend the message to you but spam servers will not. Out of the box milter-greylist will accept a resent email after 30 minutes. It means you'll get email a little later, but you can whitelist anyone you like. Works pretty well

First, I highly recommend adding the Misc and Extras repo at http://centos.karan.org - you'll need them for some of this. Just save the two .repo files to /etc/yum.repos.d - if you use yum extender you'll have to enable them in your profile as well - but we'll do all this from the command line.

Here we go - first we install a pile of software. Leave out anything you've already got installed -

yum install sendmail dovecot clamav* milter-greylist spamassassin spamass-milter pyzor perl-Razor-agent

Next we make sure sendmail works. I use sendmail but others might want to use postfix or exim. Anyway, these instructions are for sendmail

Edit /etc/sendmail.mc - change

DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA’)dnl

to

DAEMON_OPTIONS(`Port=smtp, Name=MTA’)dnl

This will lift the restriction that causes sendmail to only listen to localhost.

Also, add the following lines to sendmail.mc - add them right above the MAILER lines at the bottom of the file. Watch for word wrap here - the addition below is 9 lines long.

FEATURE(`dnsbl',`relays.ordb.org')dnl
FEATURE(`dnsbl',`list.dsbl.org')dnl
FEATURE(`dnsbl',`sbl-xbl.spamhaus.org')dnl
INPUT_MAIL_FILTER(`greylist',`S=local:/var/lib/milter-greylist/run/milter-greylist.sock')
define(`confMILTER_MACROS_CONNECT', `j, {if_addr}')
define(`confMILTER_MACROS_HELO', `{verify}, {cert_subject}')
define(`confMILTER_MACROS_ENVFROM', `i, {auth_authen}')
INPUT_MAIL_FILTER(`spamassassin', `S=local:/var/run/spamass-milter/spamass-milter.sock, F=,T=C:15m;S:4m;R:4m;E:10m')dnl
INPUT_MAIL_FILTER(`clamav', `S=local:/var/run/clamav-milter/clamav.sock, F=T, T=S:4m;R:4m')

Then rebuild sendmail.cf by opening a terminal window and typing

make -C /etc/mail

Next, we want to make sure sendmail will relay mail from machines on our local subnet - we do that by editing /etc/mail/access - I added the following lines to the file

192.168.1 RELAY
my.wan.ip.address RELAY

Both may not be necessary but I added both of them anyway. It works

Then, rebuild the access database by doing -

cd /etc/mail

makemap hash access.db < access

Okay, now let's fix dovecot. Open /etc/dovecot.conf and change

protocols = imap imaps

to

protocols = imap imaps pop3 pop3s

Next, let's get the virus scanner going. Open /etc/freshclam.conf and look for this:

Comment or remove the line below.
Example

Change it to this:

Comment or remove the line below.
#Example

You'll have to do the same thing with /etc/clamav.conf - as clamav won't run or update without the example lines commented out. I think that's because they want someone to actually look at the configuration files

milter-greylist doesn't need a whole lot of configuring unless you want to whitelist some folks or domains out of the box - you'll find the configuration file at /etc/mail/greylist.conf

On to spamassassin...

There's an excellent (but basic) configuration generator for spamassassin at

http://www.yrex.com/spam/spamconfig.php

and you can use that info to edit the real spamassassin config file at /etc/mail/spamassassin/local.cf

If you want to play with spamass-milter's configuration you'll find it at /etc/sysconfig/spamass-milter. Notice that all the flags in the file are commented out - be particularly careful of the -m flag. If you uncomment the line the -m flag will disable spamassassin subject rewriting. If you're using spamassassin to rewrite subject lines you'll want to take that -m out. I leave the -r 15 at the default. This will tell spamass-milter to reject any email with a spam score of 15 or higher. You can adjust this to your taste.

Okay, we're almost done.

Next we turn a buncha services on but don't start them yet -

chkconfig sendmail on
chkconfig dovecot on
chkconfig clamav-milter on
chkconfig milter-greylist on
chkconfig spamassassin on
chkconfig spamass-milter on

Okay. We're all done. If you're lazy like me you can reboot the machine and everything will come up now. If you're a bit more industrious or don't want to reboot the machine you can start all the services like this -

service clamav-milter start
service milter-greylist start
service spamassassin start
service spamass-milter start
service dovecot start
service sendmail start

Happy emailing
_________________
we see things not as they are, but as we are.
-- Anais Nin
Posted on: 2006/8/18 13:37
Create PDF from Post Print
Top
  •  jdonz
      jdonz
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#2
Jr Board Member
Joined: 2006/3/5
From Phoenix
Posts: 32
Great write up, thanks for sharing. You may also want to consider implementing SMTP authentication for further bulletproofing.
Posted on: 2006/8/19 23:11
Create PDF from Post Print
Top
  •  wizard
      wizard
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#3
Peeking in the Member Window
Joined: 2006/8/15
From surreal city, usa
Posts: 25
Great idea - thanks
_________________
we see things not as they are, but as we are.
-- Anais Nin
Posted on: 2006/8/20 14:58
Create PDF from Post Print
Top
  •  jerdman
      jerdman
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#4
Newbie
Joined: 2006/9/28
From
Posts: 1
That bullet proof tutorial rocked! I took your tuorial and a few others and wrote a whoel article on the subject that includes SMTP AUTH and also automatic learning for the bayesian filters. You can find it at:
Securing Your Sendmail Server

Joshua Erdman
Posted on: 2006/9/28 4:56
Create PDF from Post Print
Top
  •  lolocf
      lolocf
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#5
Newbie
Joined: 2006/12/26
From Bordeaux
Posts: 1
Hello,

this is indeed a useful post even for a winman like me .
I may just add that I heard that ordb is going out of service on January 2007.
So, one should remove it from the config.

Spamcop is a bit touchy to use.
Spamhaus is my RBL of choice.
Posted on: 2006/12/26 16:29
Create PDF from Post Print
Top
  •  locutius
      locutius
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#6
Jr Board Member
Joined: 2006/5/11
From
Posts: 47
my server is a a CentOS4.3 x86_64 full install and fully up to date
i followed the above instructions omitting only the following (which i understand is not important):

192.168.1 RELAY
my.wan.ip.address RELAY


i attempt to send a mail from admin@mysite.com to me@mysite.com (both users are created with passwords) using squirrelmail i see this error (with firewall enabled and disabled):

Email delivery error
Server replied: 69 Can't execute command '/usr/sbin/sendmail -i -t -fadmin@mysite.com'.


i then try to send to admin@mysite.com from me@gmail.com

the maillog reads:

Jan 19 03:05:01 h33t sendmail[480]: l0J251OM000480: from=root, size=295, class=0, nrcpts=1, msgid=<200701190205.l0J251OM000480@mysite.com>, relay=root@localhost
Jan 19 03:05:01 h33t sendmail[575]: l0J251Rh000575: tcpwrappers (localhost, 127.0.0.1) rejection
Jan 19 03:05:01 h33t sendmail[480]: l0J251OM000480: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30295, relay=[127.0.0.1] [127.0.0.1], dsn=5.0.0, stat=Service unavailable
Jan 19 03:05:01 h33t sendmail[480]: l0J251OM000480: l0J251ON000480: DSN: Service unavailable
Jan 19 03:05:01 h33t sendmail[480]: l0J251ON000480: to=root, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31319, relay=[127.0.0.1], dsn=5.0.0, stat=Service unavailable
Jan 19 03:05:01 h33t sendmail[480]: l0J251ON000480: l0J251OO000480: return to sender: Service unavailable
Jan 19 03:05:01 h33t sendmail[480]: l0J251OO000480: to=postmaster, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32343, relay=[127.0.0.1], dsn=5.0.0, stat=Service unavailable
Jan 19 03:05:01 h33t sendmail[480]: l0J251ON000480: Losing ./qfl0J251ON000480: savemail panic
Jan 19 03:05:01 h33t sendmail[480]: l0J251ON000480: SYSERR(root): savemail: cannot save rejected email anywhere
Jan 19 03:05:06 h33t milter-greylist: l0J256pw006358: addr 64.233.162.233 from <me@gmail.com> to <admin@mysite.com> delayed for 00:30:00
Jan 19 03:05:06 h33t sendmail[6358]: l0J256pw006358: Milter: to=<admin@mysite.com>, reject=451 4.7.1 Greylisting in action, please come back in 00:30:00
Jan 19 03:05:06 h33t sendmail[6358]: l0J256pw006358: from=<me@gmail.com>, size=0, class=0, nrcpts=0, proto=ESMTP, daemon=MTA, relay=nz-out-0506.google.com [64.233.162.233]


i then also tried with this configuration in the sendmail.mc from this page http://www.redhat.com/magazine/025nov06/features/email/index.html

DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl ... change to - DAEMON_OPTIONS(`Port=smtp, Name=MTA')
LOCAL_DOMAIN(`localhost.localdomain')dnl ... change to - LOCAL_DOMAIN(`emailjunkie.org')
dnl MASQUERADE_AS(`mydomain.com')dnl ... change to - MASQUERADE_AS(`emailjunkie.org')
dnl FEATURE(masquerade_envelope)dnl ... change to - FEATURE(`masquerade_envelope')
and added the line ... FEATURE(`allmasquerade')

and received the same error:

Email delivery error
Server replied: 69 Can't execute command '/usr/sbin/sendmail -i -t -fadmin@mysite.com'.


this time the maillog reads:

Jan 19 03:22:20 mysite sendmail[8150]: l0J2MKlq008150: Authentication-Warning: mysite.com: apache set sender to me@mysite.com using -f
Jan 19 03:22:20 mysite sendmail[8150]: l0J2MKlq008150: from=me@mysite.com, size=525, class=0, nrcpts=1, msgid=<4024.86.138.26.160.1169173340.squirrel@www.mysite.com>, relay=apache@localhost
Jan 19 03:22:20 mysite sendmail[8592]: l0J2MKlT008592: tcpwrappers (localhost, 127.0.0.1) rejection
Jan 19 03:22:20 mysite sendmail[8150]: l0J2MKlq008150: to=admin@mysite.com, ctladdr=me@mysite.com (502/503), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30525, relay=[127.0.0.1] [127.0.0.1], dsn=5.0.0, stat=Service unavailable
Jan 19 03:22:20 mysite sendmail[8150]: l0J2MKlq008150: l0J2MKlr008150: DSN: Service unavailable
Jan 19 03:22:20 mysite sendmail[8150]: l0J2MKlr008150: to=me@mysite.com, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=31549, relay=[127.0.0.1], dsn=5.0.0, stat=Service unavailable
Jan 19 03:22:20 mysite sendmail[8150]: l0J2MKlr008150: l0J2MKls008150: return to sender: Service unavailable
Jan 19 03:22:20 mysite sendmail[8150]: l0J2MKls008150: to=postmaster, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32573, relay=[127.0.0.1], dsn=5.0.0, stat=Service unavailable
Jan 19 03:22:20 mysite sendmail[8150]: l0J2MKlr008150: Losing ./qfl0J2MKlr008150: savemail panic
Jan 19 03:22:20 mysite sendmail[8150]: l0J2MKlr008150: SYSERR(apache): savemail: cannot save rejected email anywhere


the problem in both instances appears to be tcpwrappers (localhost, 127.0.0.1) rejection and DSN: Service unavailable

please i ask your help

thank you in advance for any help you can offer
Posted on: 2007/1/19 3:01
Create PDF from Post Print
Top
  •  jult
      jult
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#7
Jr Board Member
Joined: 2007/1/4
From Amsterdam, .NL
Posts: 40
But why would anyone still use sendmail if postfix is available as well? (hence all the errors!)

And spamassassin is only interesting if you're ready to spend about 1 to 4 hours daily on administrating it, and have a load of RAM and CPU-space left. All this is not what spam is for.
Posted on: 2007/1/19 5:03
Create PDF from Post Print
Top
  •  phoenix
      phoenix
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#8
Regular Board Member
Joined: 2005/9/7
From
Posts: 132
Why would anyone bother with this type of setup when you can have a mailserver up and running in about 1 hour with amavis, spamassassin, dpsam, mysql, tomcat etc. etc. - just try using Zimbra It's extremely easy to set-up and save the hassle of trying to integrate multiple packages.

I was a complete novice with Linux (I still am) and I managed to do it real easy, I've posted the link before but for posterity here it is again - www.zimbra.com Two versions available a paid-for version and for cheapskates like me an Open Source version with all the features you'd need.
_________________
Regards


Bill
Posted on: 2007/1/19 14:20
Create PDF from Post Print
Top
  •  locutius
      locutius
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#9
Jr Board Member
Joined: 2006/5/11
From
Posts: 47
thanks for the advice. if you can't beat 'em ....

meanwhile, where is the sendmail guru? sendmail is possible it is a redhat basic
Posted on: 2007/1/20 22:39
Create PDF from Post Print
Top
  •  jult
      jult
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#10
Jr Board Member
Joined: 2007/1/4
From Amsterdam, .NL
Posts: 40
Quote:

phoenix wrote:
Why would anyone bother with this type of setup when you can have a mailserver up and running in about 1 hour
with amavis, spamassassin, dpsam, mysql, tomcat etc. etc. - just try using Zimbra

Any package that 'integrates' MySQL is asking for RAM, CPU, time and dependencies
many people don't feel like having.
Why would anyone use MySQL for mail-integration, even? The monstrosity
of using separate databases when it's all just lines of text we have to parse!
Flatfile would do just fine.

I say: Postfix, dovecot, clamd, clamsmtp with decent config will do just fine.
Amavis and Spamassassin are monsters, both administrative and memory/cpu-wise.

By the way, why is this forum running on such a strange UI?
punBB or phpBB are still so much better.
Posted on: 2007/1/21 5:21
Create PDF from Post Print
Top
  •  msimpson
      msimpson
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#11
Newbie
Joined: 2007/3/3
From
Posts: 4
Hi,

We are planning on migrating to procmail? What do we need to do to convert our sendmail config?

Matt
Posted on: 2007/3/3 13:43
Create PDF from Post Print
Top
  •  arrfab
      arrfab
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#12
Moderator
Joined: 2005/1/3
From /country/belgium
Posts: 864
Quote:

msimpson wrote:
Hi,

We are planning on migrating to procmail? What do we need to do to convert our sendmail config?

Matt


They're not designed to do the same thing : procmail is a mail delivery agent (mda) and sendmail is a mail transfert agent (mta)
By default sendmail uses procmail to deliver mail locally ! so maybe you have to explain us (better) what you're trying to do ...
_________________
idea=`grep -i clue /dev/brain` ; test -z "$idea" && echo "sorry, init 6 in progress" || sh ./answer-the-forum
Posted on: 2007/3/3 18:38
Create PDF from Post Print
Top
  •  msimpson
      msimpson
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#13
Newbie
Joined: 2007/3/3
From
Posts: 4
Hi,

Sorry I meant Postfix. Using this howto what are the steps involved in switch from sendmail -> postfix?

Matt

Quote:

arrfab wrote:
Quote:

msimpson wrote:
Hi,

We are planning on migrating to procmail? What do we need to do to convert our sendmail config?

Matt


They're not designed to do the same thing : procmail is a mail delivery agent (mda) and sendmail is a mail transfert agent (mta)
By default sendmail uses procmail to deliver mail locally ! so maybe you have to explain us (better) what you're trying to do ...
Posted on: 2007/3/4 0:40
Create PDF from Post Print
Top
  •  fakrul
      fakrul
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#14
Newbie
Joined: 2007/3/25
From Dhaka
Posts: 2
Hello, I have also installed postfix, mailscanner, postgrey and clamav in centos as antispam-antivirus gateway. It works great for me. Also installed vispan & mailscanner mailwatch to monitor the server. I have write a document and like to share with you people. You can get the doc here.
http://www.fakrul.com/demo/antispam.php
Posted on: 2007/3/25 6:30
Create PDF from Post Print
Top
  •  dougp23
      dougp23
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#15
Peeking in the Member Window
Joined: 2006/12/6
From
Posts: 22
Well What the Heck, I'll post mine too!

Mine is Scalix email server (http://scalix.com)
Very nice user interface, talks to Outlook for calendars and scheduling and all that nonsense.
Basically an Exchange drop in.

So, if you wanna see my HOWTO, CentOS4.4, Scalix, spamassassin and clamav,
it's here:

http://www.swifttide.com/Scalix_Setup.html
Posted on: 2007/3/31 0:04
Create PDF from Post Print
Top
  •  msimpson
      msimpson
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#16
Newbie
Joined: 2007/3/3
From
Posts: 4
Hi All.

I cant seem to be able to update clamav via yum? The kbs-CentOS doesn't seem to be up to date. How do I update clamav to latest version?

daily.cvd updated

**Unmatched Entries**
nonblock_connect: connect timing out (30 secs): 1 Time(s)
WARNING: Your ClamAV installation is OUTDATED!: 459 Time(s)
WARNING: Current functionality level = 10, recommended = 14: 199 Time(s)
DON'T PANIC! Read http://www.clamav.net/faq.html: 459 Time(s)
WARNING: Current functionality level = 10, recommended = 15: 78 Time(s)
WARNING: Mirror 193.1.193.64 is not synchronized.: 7 Time(s)
WARNING: Local version: 0.88.7 Recommended version: 0.90.1: 97 Time(s)
WARNING: Invalid DNS reply. Falling back to HTTP mode.: 1 Time(s)
WARNING: Local version: 0.88.7 Recommended version: 0.90.2: 85 Time(s)
Trying again in 5 secs...: 7 Time(s)
Posted on: 2007/4/23 0:17
Create PDF from Post Print
Top
  •  linker3000
      linker3000
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#17
Newbie
Joined: 2007/7/13
From
Posts: 1
"So, if you wanna see my HOWTO, CentOS4.4, Scalix, spamassassin and clamav,
it's here:

http://www.swifttide.com/Scalix_Setup.html"

Doug - the above link goes to a black hole but I'd appreciate seeing the notes as I am about to embark on a Scalix trial.

Thanks
Posted on: 2007/7/13 9:05
Create PDF from Post Print
Top
  •  dougp23
      dougp23
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#18
Peeking in the Member Window
Joined: 2006/12/6
From
Posts: 22
Yikes! bad link. it's here:

http://www.swifttide.com/scalix/Scalix_Setup.html

Good luck! Check out the forums on the scalix site, lot of good info.
Scalix just got bought by Xandros, not sure if that's good or bad...
Posted on: 2007/8/12 0:25
Create PDF from Post Print
Top
  •  LinOSuar
      LinOSuar
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#19
Newbie
Joined: 2007/2/1
From
Posts: 4
The Repositories page on the CentOS Wiki indicates that the Priorities plugin for Yum should be installed before using 3rd party repositories, such as the ones mentioned above.

LinOSuar
Posted on: 2007/8/20 15:38
Create PDF from Post Print
Top
  •  cry4dawn
      cry4dawn
Re: HOWTO: Pretty much bulletproof (and spam-proof) email...
#20
Regular Board Member
Joined: 2009/9/23
From
Posts: 103
This did not work at all for me, se linux balked on almost everything. I did achieve the same thing via a slighlty different path
sendmail Mailscanner clamav howto

works great on Centos 5.3 I am also using APF, BFD, LES, PRM, LSM, chrootkit, rkhunter for more seccurity also here is a trick if you are using your server as an outgoing relay only add the following to the end of your /etc/mail/access

1 ERROR:"551 We do not accept mail sent directly to our servers. You must use the valid MX record of the domain that you are sending to."
2 ERROR:"551 We do not accept mail sent directly to our servers. You must use the valid MX record of the domain that you are sending to."
3 ERROR:"551 We do not accept mail sent directly to our servers. You must use the valid MX record of the domain that you are sending to."
4 ERROR:"551 We do not accept mail sent directly to our servers. You must use the valid MX record of the domain that you are sending to."
5 ERROR:"551 We do not accept mail sent directly to our servers. You must use the valid MX record of the domain that you are sending to."
6 ERROR:"551 We do not accept mail sent directly to our servers. You must use the valid MX record of the domain that you are sending to."
7 ERROR:"551 We do not accept mail sent directly to our servers. You must use the valid MX record of the domain that you are sending to."
8 ERROR:"551 We do not accept mail sent directly to our servers. You must use the valid MX record of the domain that you are sending to."
9 ERROR:"551 We do not accept mail sent directly to our servers. You must use the valid MX record of the domain that you are sending to."


this will cause everything that you have not specifically configured to recieve from not be able to use your mail server.

rember to makemap hash access < access and restart your sendmail
Posted on: 2009/9/24 12:17
Create PDF from Post Print
Top
 Top   Previous Topic   Next Topic

 


 You cannot start a new topic.
 You can view topic.
 You cannot reply to posts.
 You cannot edit your posts.
 You cannot delete your posts.
 You cannot add new polls.
 You cannot vote in polls.
 You cannot attach files to posts.
 You cannot post without approval.




"Linux" is a registered trademark of Linus Torvalds. | All other trademarks are property of their respective owners. | All other content is Copyright @ 2004-2009 by the CentOS Project or "each individual contributor (forums, comments, etc.) unless otherwise assigned".| Theme based on a theme by 7dana.com