Linux Server How ToHow To Setup, Configure, Manage and Secure a Linux Server |
|
Home Which Linux Distribution? Linux Server Hardware Linux Server Security Linux Web Server - Apache Linux DNS Server - Bind Linux DHCP Server - DHCPD Linux Mail Server - Sendmail Introduction to Sendmail Install Sendmail With Apt Compile Sendmail MX Records Configure Sendmail Users, Relays and Domains Filtering Spam LDP How To's About This Site |
Linux Server How To - Configure Sendmail Users and DomainsConfigure Sendmail Users and DomainsThere are two aspects to sendmail which we can configure. We can configure Sendmails behaviour such as queues, timeout intervals and additional features such as milters through sendmail.cf and submit.cf. We can also configure users, domains and relaying through the local configuration files such as aliases, access, local-host-names and relay-domains. This article shall endevour to familiarize the reader with the everyday configuration of Sendmail, users, virtual users, relays and domains. If you wish to change Sendmails behaviour or included options please read our article on Configuring Sendmail.The most common location for the configuration files for sendmail is in the /etc/mail directory. The files you will likely find yourself editing the most are virtusertable, aliases, access, local-host-names and possibly relay-domains. Generally speaking, sendmail delivers mail to a local user account on the primary mail server and each individual mailbox needs a corresponding user account. To muddy the waters somewhat you can also have aliases and virtual addresses set up to map emails with different addresses to one local user account. Using aliases you can even map emails with one particular recipient to several different local user accounts so that more than one person will receive it. That probably all sounds more confusing than it actually is. Let start by examining a reasonably simple mail server set up, a mail server that receives mail for one particular domain. This will get a lot of readers mail servers running in the space of a few paragraphs then we can focus on a mail server that receives mail for multiple domains, uses aliases and virtual email addresses.
Now our Linux Sendmail server will accept mail for the above three domains, yourdomain.com, anotherdomain.com and example.net. And here is where one of Sendmail's caveats presents itself. Using our user fred that we added earlier as an example, if someone sends an email to fred@yourdomain.com, fred@anotherdomain.com and fred@example.net they will all arrive in the fred mailbox. This is because the default behaviour of Sendmail is to deliver mail to a matching local user account if a virtual user or alias that matches the address cannot be found. This can be very useful behaviour, I have many domains hosted on one mail server and an email to webmaster as an example will arrive in the one mail box. I only have to check one account to receive the mail to all of these addresses. This is easily changed by using the virtual user table if you host many domains and have many different freds (or any other user for that matter).
AliasesAliases are another way to direct mail addressed to one recipient and deliver it to another. There are instances where there is overlap between the role of the virtual user table and aliases where you can use either to achieve a given end but aliases are more often used when manipulating mail boxes rather than virtual addresses. Aliases, like the virtual user table, have a text source file that is mapped to a database though its layout is slightly different. The makemap command should not be used to map your aliases database as this will cause erratic mail delivery and cripple your mail server. The newaliases command should be used instead. Lets have a look at the aliases text file below.
The webmaster and abuse aliases are very straightforward, note that the format is alias then a colon then a tab and then the local account to which the mail should be delivered. The sales alias has three recipients Peter, Paul and Mary with a comma and a space between the local mail boxes. The final example here follows on from a virtual address, sales@yourdomain.com is directed to yd_sales in the virtusertable and then directed to yd_fred and yd_karen through aliases. There need not even be a local account yd_sales for this to work. After you edit the aliases file use the newaliases command to map the changes you have made.
The Access MapBy default Sendmail will receive mail from any sender but will only send mail if it is being sent from the localhost address. This is the ideal configuration to prevent spammers from using your mail server to relay their garbage to the world. The access map, like the virtual user table, is a hash database (access.db) and an accompanying text file (access) which is edited to control mail being sent and received by your mail server. The access file is edited and then the access database is mapped using the makemap command. Entries in the access map should be preceded with one of three tags according to its type-Connect: connection information (${client_addr}, ${client_name}) From: envelope sender To: envelope recipient As a minimum you would require that your users can send mail through the mail server and this is accomplished by specifying the hosts or IP address ranges that your users are connected followed by the value RELAY. You may also elect to REJECT mail from particular senders or domains. Here are a few examples-
In the above example the mail server will relay mail from any yourdomain.com host and also from hosts on the 192.168.1.0/24 network. Any email from viagra.com or any email to fred@yourdomain.com will be rejected. Once you have edited access you need to map the access database by using the makemap command while in the /etc/mail directory.
Relay Domains - Acting as a Secondary Mail ServerSetting up a secondary mail server is really easy with sendmail. First ensure that your MX records are correct and the mail server has an appropriate weight for a secondary mail server then add the domain that you wish to provide secondary mail services for into the relay-domains file in /etc/mail. Make sure you restart sendmail for the changes to take effect. Note that your mail server can perform more than one role at once, it may be secondary mail server for several domains and primary mail server for several others without any issues.
|
| © 2009 www.linuxserverhowto.com |