Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get Sendmail acting as a Relay Server

Mail Relaying

How to get Sendmail acting as a Relay Server

by  TalentedFool  Posted    (Edited  )
At my company we have an Internal MS Exchange 5.5 Machine that we use as our main mail server. We used to dial-up to our ISP from this machine every 30 minutes to download our emails but just recently added an Broadband connection so now have a permanent connection to the internet. WeÆve got a firewall and router in place and I am not going to go into configuring these fully here but basically you need TCP ports 25 and UDP 53 open for SMTP and Domain queries. The following describes how we implemented an SMTP RELAY server in our DMZ to collect mail from the Exchange server and send it to the outside world and vice versa for e-mails addressed to our company.

All the files except the mydomain.com.m4 file described here are located within the /etc/mail directory on a Red Hat Linux 8 distro machine and you mey need to modify these paths accordingly for your distro

The sendmail.mc file is the first file we need to look at when we configure sendmail. Modify the contents to look like the following:

divert(-1)
include(`/usr/share/sendmail-cf/m4/cf.m4')
OSTYPE(`linux')
DOMAIN(`mydomain.com')dnl
Cwlocalhost.localdomain

The main line that we are interested in is the æDOMAIN(`mydomain.comÆ)dnl line. This line tells the M4 compile program to look into the æ/etc/share/sendmail-cf/domain directory for a configuration file named æmydomain.com.m4Æ .

Edit the file æ/etc/share/sendmail-cf/domain/mydomain.com.m4Æ and make it look like the following. If the file does not exist then create it. Obviously you can add other features as required. The ones I have used below suite my needs

divert(-1)
FEATURE(always_add_domain)dnl
FEATURE(`masquerade_entire_domain')
FEATURE(`masquerade_envelope')
FEATURE(`allmasquerade')
MASQUERADE_AS(`mydomain.com')
MASQUERADE_DOMAIN(`mydomain.com')
MASQUERADE_AS(mydomain.com)
FEATURE(`mailertable')
FEATURE(relay_entire_domain)dnl
FEATURE(access_db)dnl
FEATURE(`blacklist_recipients')dnl
FEATURE(nouucp,reject)dnl
FEATURE(`redirect')dnl
MAILER(local)dnl
MAILER(smtp)dnl

Relay Domains

Edit/create the file located in the /etc/mail directory and put the following entry only:

mydomain.com

The Access Database

Edit the access file so that it looks like below.

#localhost.localdomain RELAY
#localhost RELAY
#127.0.0.1 RELAY
mydomain.com RELAY
exchange server IP RELAY

Once you have completed the changes then you need to compile the access database. This can be done by using the command:

makemap hash /etc/mail/access < /etc/mail/access

Mailertables

Edit/create the file within the /etc/mail directory as shown below placing the IP address of the machine within the square brackets. We use an IP address as our Relay machine in the DMZ cannot query our Internal DNS Server.

mydomain.com esmtp:[ip address of machine]


Once all the files have been created you will need to compile the sendmail configuration using the command

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

After you have done this then restart sendmail

/etc/init.d/sendmail restart

See how that goes for you!!
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top