When you're setting up servers the last thing you want to have to do is put in an all nighter in order to get Sendmail accepting email from outside of your local network. If you're new to Linux this can be a real nightmare. The good news is once this is configured, it'll just keep on working until you take it down. But getting Sendmail to the point where it is working correctly can be a real nightmare.
In this article I will give you a step by step setup for getting Sendmail to accept email from outside of localhost and your own LAN. This will require you to manually edit some configuration files and you will need root access (or sudo access) in order to do this.
In order for this to work I am going to assume you have your own domain name. For the sake of this article we'll illustrate with the sample domain www.sampledomain.com. I will also assume this FQDN is working properly and you have Sendmail already installed and starts properly. The operating system I am using for this example is Ubuntu Server 8.10. With that in mind, let's get to this.
All of the configurations you will be doing will be within the /etc/mail directory. In this directory you will be modifying the following:
Once all of the modifications are made you will then restart Sendmail.
By default Sendmail is setup to only accept mail from localhost. This is the first change that needs to be made. This change is made in the sendmail.mc file. What you are looking for is the following line:
DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Addr=127.0.0.1, Port=smtp')dnl
The line needs to be altered to look like:
DAEMON_OPTIONS(`Family=inet, Name=MTA-v4, Port=smtp')dnl
The Addr=127.0.0.1 section instructs Sendmail to only accept email from localhost.
Now you need to add these changes to the sendmail.cf file by issuing the command:
sudo make -C /etc/mail
This will add your changes. The reason I use sendmail.mc for these options is that configuring the DAEMON_OPTIONS is a bit confusing and hard to find. The other options are quite easy to add directly to sendmail.cf.
The options you will want to add in this file are for setting your domain name. The first option is under the "my official domain name" heading. What you will see in the example is:
replace this with (and remember we're using our sample domain):
The next option will be set for masquerading. In some recent Sendmail releases this is not in the cf by default. Take a look for the quoting section that looks like:
# dequoting map
# class E: names that should be exposed as from this host, even if we masquerade
# class L: names that should be delivered locally, even if we have a relay
# class M: domains that should be converted to $M
# class N: domains that should not be converted to $M
At the bottom of this add:
# who I masquerade as (null for no masquerading) (see also $=M)
Now you are done with the sendmail.cf file.
This file defines access control to your mail server. For our sample we will add the following to the bottom of this file:
Save that file and you have one more configuration to take care of.
This file will define the host names associated with your Sendmail server. In this file we will add:
It is now time to restart Sendmail. Do this with the command:
Once sendmail restarts you should be accepting email from the outside world. Run a test with an email address outside of your domain.
Sendmail isn't really as difficult as it is made out to be. With this simple walkthrough you should have Sendmail accepting mail from all over quickly and easily.Advertisement
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.