Thursday, January 25, 2007

How to configure sendmail as a gateway

This is a simple how to about how to configure sendmail to act as a mail
gateway.

This how to will only talk about 3 files: access, mailertable and
relay-domains.

File relay-domains NOT included in sendmail distribution (at least in my
CentOS distribution), you have to create it manually.
All files (at least in my CentOS) located in directory /etc/mail

Access file
First, we put our host and our network to be able to relay through our
server.
localhost.localdomain RELAY
localhost RELAY
127.0.0.1 RELAY
192.168.1 RELAY
192.168.2 RELAY

If you use GreetPause feature, you can put no waiting for local email.
GreetPause:localhost 0
GreetPause:192.168.1 0
GreetPause:192.168.2 0

If you using DNSBL, and want to skip one or two domains from DNSBL check,
you can use this
Connect:friendlydomain.com OK

Now for the big part.
Put all the domain that you want to relay BUT put it as REJECT. This way by
default all emails to that domain will be rejected unless we specify
otherwise - in this case OK.

indomino.net REJECT
blablabla.org REJECT
something.edu REJECT

user1@indomino.net OK
user2@indomino.net OK
user3@indomino.net OK

user1@blablabla.org OK
user2@blablabla.org OK

user1@something.com OK

Finish. For access file, you can use make -C /etc/mail to 'compile' it.

Mailertable file
Now put this entry in mailertable, so sendmail will know to where it will
route the emails.
indomino.net smtp:smtp.indomino.net
blablabla.org smtp:[192.168.1.25]
something.edu esmtp:[192.168.1.50]

Finish. Do make -C /etc/mail to 'compile' it.

Relay-domains file.
Most forgotten file, I think because it's not included in most
distribution. You have to create it manually. Simply as type touch
/etc/mail/relay-domains to create the file.

Now type all the domain that you want to relay.
indomino.net
blablabla.org
something.edu

Finish. Now restart the server.

0 comments:

Template Designed by Douglas Bowman - Updated to Beta by: Blogger Team
Modified for 3-Column Layout by Hoctro