# Basic Setup for Sendmail Mail Server

**URL:** <https://forums.thehomestack.io/t/basic-setup-for-sendmail-mail-server/4243>\
**Category:** Linux - General\
**Created:** [February 10, 2013, 1:53pm UTC](https://forums.thehomestack.io/t/basic-setup-for-sendmail-mail-server/4243 "2013-02-10T13:53:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve.ling](https://forums.thehomestack.io/letter_avatar_proxy/v4/letter/s/d6d6ee/32.png) [@steve.ling](https://forums.thehomestack.io/u/steve.ling)\
**Post date:** [February 10, 2013, 1:53pm UTC](https://forums.thehomestack.io/t/basic-setup-for-sendmail-mail-server/4243/1 "2013-02-10T13:53:18Z")

</div>

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:

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

```

and your sendmail.mc file

```auto
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 :

```auto
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:

```auto
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.

```auto
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:

```auto
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.

```auto
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](http://mail.example.com) you would enter it like this.

```auto
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:

```auto
sendmail -bd

```
