Sendmail Configuration for Linux (Fedora 11)
This is very similar to the Solaris configuration but the supplied .mc file for linux has rather more FEATURE lines and configuration to start with.
The first step is to allow a linux system connected to the internet to send and receive email and to rewrite the addresses as user@domainname
There are two parts to this, one is sendmail configuration and the second is DNS configuration.
Sendmail configuration
First of all we need to create a custom sendmail config file. it is not necessary to edit sendmail.cf files directly, its much easier to generate them from the m4 macro files.
The m4 files on Fedora 11 can be found in /etc/mail/
The standard server sendmail m4 file is called sendmail.mc. Make a copy of the original file so it is easy to backout the changes
First find the line that restricts the sendmail process to only listen on its loopback interface, this is the DAEMON_OPTIONS line which mentions 127.0.0.1.
Then comment it out.
Change:
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
to:
dnl # DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
Next set the MASQUERADE options to rewrite the outgoing address
MASQUERADE_AS(`mydomain.com')dnl
dnl # masquerade not just the headers, but the envelope as we
dnl #
FEATURE(masquerade_envelope)dnl
dnl #
dnl # masquerade not just @mydomainalias.com, but @*.mydomain
dnl #
FEATURE(masquerade_entire_domain)dnl
dnl #
dnl MASQUERADE_DOMAIN(mydomain.com)dnl
The MASQUERADE_AS line makes all email appear to come from the domain not from the hostname of the system.
#cd /etc/mail
#make
This will produce a new sendmail.cf file
Edit /etc/mail/local-host-names to add the domains that you want to allow relaying for
#vi /etc/mail/local-host-names
mydomain.com
myotherdomain.com
Then restart Sendmail.
service sendmail stop
service sendmail start
DNS configuration
Add the required MX records to the DNS zone file(s) for your domain(s) similar to the examples below:
mydomain.com IN MX 10 mymailserver.mydomain.com
myotherdomain.com IN MX 10 mymailserver.mydomain.com
Done ! - Your system should now accept and send email and rewrite outgoing addresses as user@domainname
Using Genericstable feature for rewriting outgoing mail addresses
The generics table can be used to rewrite outgoing mail with more specific requirements for different domains. It allows mail from different users to appear to come from different domains.
Add the following to the sendmail m4 file
FEATURE (`genericstable')
GENERICS_DOMAIN_FILE (`/etc/mail/generics-domains')
The genericstable FEATURE should be added near the end of the file just before the mailer options. If it is added near the beginning of the file the names will not be rewritten correctly.
Run make to make the new custom sendmail config file.
#cd /etc/mail
#make
Edit /etc/mail/generics-domains to add the domain name that gets set by default, typically the hostname
eg,
myhost.mydomain.com
Edit /etc/mail/genericstable to add the users that you want to rewrite outgoing mail for
eg
fred fred@mydomain.com
tom tom_jones@hisdomain.com
bill billybob@myotherdomain.com
Now we need to make the generics table into a map. There are different formats like hash dbm etc. These can be seen by typing 'makemap -l'. The default is type hash which will produce a .db file.
# makemap hash /etc/mail/genericstable < /etc/mail/genericstable
Then restart Sendmail.
service sendmail stop
service sendmail start