Sendmail: Basic Setup
Server Training - Mail Server

Basic Setup for Sendmail Mail Server

 

By default sendmail does not allow network connections to the mail server. This is simply a security issue and of course if you want to create a mail server, you need to change this. The first thing to do is create a back-up of your sendmail.cf file and sendmail.mc file:

cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf_bac

and your sendmail.mc file

cp /etc/mail/sendmail.mc /etc/mail/sendmail.mc_bac

Now in the sendmail.mc file you will see a line that looks like this :

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

This line only allows connections on the local interface, which is default (127.0.0.1). You can comment out this line in the sendmail.mc file by adding this dnl like so:

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

Or you could edit the line and change the Addr=your IP Address

Next a basic security feature would be to stop accepting unresolvable domains. This is used so that if your DNS does not know the exact address to resolve to your mail will still function. However, with the onset of spam if you can get your DNS to function correctly then you will want to turn this off so a spammer cannot fake a domain name. Again place a dnl in from of the line.

dnl FEATURE(`accept_unresolvable_domains´)dnl

Once you have saved the altered sendmail.mc file then you need to run the make command so you do not have to edit the sendmail.cf file, here’s how:

make -C /etc/mail

This command will process all of the files in the /etc/mail directory at once

 

/etc/mail/access

The file /etc/mail/access can list domains that you will accept or deny connections for mail. The access file is created and then you will need to rebuild sendmail and the access file is transformed into a database that sendmail will access called access_db. Here is the format that it takes in the access file:

Include your domain in the access file.

 

SpamDelux.com REJECT

NewSpamforYou.net DISCARD

example.com OK

192.168.5 550 We cannot relay mail for your subnet

 

There are five ways to respond to sites listed in the database.

REJECT refuse sender or recipient and send error message

DISCARD refuse sender or recipient and do not send error message

RELAY accept and relay mail

OK accept mail even if another rule might reject the mail



Modify /etc/hosts
You should modify your /etc/hosts file to reflect the FQDN of your mail server. If your Fully Qualified Domain Name was mail.example.com you would enter it like this.

127.0.0.1 mail.example.com example.com localhost localdomain mail

 

Run in Daemon Mode

If you want to run sendmail in daemon mode you will need to tell it to do so, run this command:

sendmail -bd

 


Copyright CyberMontana Inc. and BeginLinux.com
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874