Introduction
Sendmail implements a general purpose internetwork mail routing facility. This document explain how to install sendmail and run an email server which will send and receive mail using the SMTP protocol.
An IMAP or POP3 server is required to retrieve mail using Eudora or MS Outlook. Sendmail does not offer POP3 or IMAP services.
Installation
Prerequisites
You should have a basic knowledge of UNIX and DNS.
The server should allow incoming connections to the SMTP service which will be listening on TCP port 25.
The server should have a fully qualified hostname (FQDN) such as mail.example.net.
The hostname should resolve to an A record. It should not be a CNAME.
The MX record for the domain for which you wish to receive mail should point to the hostname of your server.
There should a PTR record for the IP address of your server. Mail from your server may be rejected if there is no reverse DNS.
Installing sendmail
Download the sendmail source code from the sendmail website.
- Extract the files from the downloaded file.
- Change the current directory to where the sendmail source code was extracted.
- Enter the following command:
sh Build
- If there are no errors, you may continue with the installation.
- If you are installing sendmail 8.12.x, 8.13.x, or 8.14.x
- Verify whether you have a user smmsp. Create the user if it does not exist. The user should not be assigned a login shell.
- Verify whether you have a group called smmsp.
- Enter the following command:
sh Build install
The sendmail binary is now installed. The next step is to configure sendmail.
Configuring sendmail
The main configuration file for sendmail is the /etc/mail/sendmail.cf file. Starting with version 8.12, sendmail uses the /etc/mail/submit.cf configuration file for mail submission. The .cf files are complex to understand. It is recommended that you create a .mc configuration file and use the M4 (macro processor) to generate the .cf file.
There are some sample .mc configuration files in the cf/cf/ directory of the sendmail source code. Alternatively, you can use one of the sample configuration files available from this website . You should edit the .mc file with a UNIX text editor such as vi.
- Change the current directory to cf/cf directory.
- Copy your .mc configuration file to the current directory as sendmail.mc.
- To generate the sendmail.cf, enter the following command:
sh Build sendmail.cf
- To install the sendmail.cf as /etc/mail/sendmail.cf and submit.cf as /etc/mail/submit.cf, enter the following command:
sh Build install-cf
The following sample configuration files are available for download. If you are using a smarthost, you will find a sample configuration here .
If you already have sendmail installed and configured, you can generate a new sendmail.cf file by using the following command:
m4 directory/m4/cf.m4 config.mc > sendmail.cf
The directory for the sendmail m4/cf.m4 file depends on the operating system you are using:
- Debian /usr/share/sendmail.cf
- FreeBSD /usr/share/sendmail/cf
- MacOS X /usr/share/sendmail/conf
- OpenBSD /usr/share/sendmail
- NetBSD /usr/share/sendmail/cf
- RedHat /usr/share/sendmail-cf or /usr/lib/sendmail-cf
- Slackware 8.0 /usr/src/sendmail/
- Slackware 8.1 /usr/share/sendmail/cf
- Solaris /usr/lib/mail
On Solaris, for example, type:
m4 /usr/lib/mail/m4/cf.m4 config.mc > sendmail.cf
Verify whether you have the following files in /etc/mail
- local-host-names
- relay-domains
- aliases
- access
The local-host-names file should contain the domain name for which your mail server should accept mail. It is recommended that you also add localhost to this file. Each entry should be on a new line.
If there is no relay-domains file, create one with the following command:
touch /etc/mail/relay-domains
The aliases file should contain the following entries at least:
postmaster: root
abuse: root
security: root
In the above example, postmaster is an alias for the root mailbox. The following command will generate the aliases table:
newaliases
You can create a new access file by typing
touch /etc/mail/access
The default database map type for Linux, FreeBSD, NetBSD or OpenBSD is hash. Type the following to generate the data bases:
makemap hash /etc/mail/access < /etc/mail/access
If you are using the smarthost.mc or smarthost-dialup.mc, create a genericstable file and type:
makemap hash /etc/mail/genericstable < /etc/mail/genericstable
You can now start sendmail.
Sendmail administration
Starting sendmail
The sendmail MTA can be started with the following command:
/usr/sbin/sendmail -L sm-mta -bd -q30m
or
/usr/sbin/sendmail -bd -q30m (versions 8.9.x, 8.10.x, 8.11.x)
The Mail Submission Agent listens for incoming connections on TCP port 587.
If you are using sendmail 8.12, 8.13 or 8.14, enter the following command to start the Mail Submission Program:
/usr/sbin/sendmail -L sm-msp-queue -Ac -q30m
Shutting down sendmail
You can shutdown sendmail by entering the following command:
kill `head -1 /var/run/sendmail.pid`
Viewing the mail queue
You can display the contents of the mail queue with the following command:
/usr/bin/mailq
Process messages saved in the mail queue
You can process messages saved in the mail queue with the following command:
/usr/sbin/sendmail -q
Troubleshooting
Verifying whether sendmail is running
You can verify whether sendmail is running by running the following command:
telnet localhost 25
You will see the sendmail banner which shows the version of sendmail you are using. Type quit and press Enter to exit to the shell.
Testing SMTP
A SMTP test can be done to verify email delivery. Type:
telnet mail.example.net 25
Type the text in bold when you see the following and press Enter
SERVER:220 local ESMTP Sendmail 8.13.5/8.13.5; Wed, 15 Mar 2006 01:51:21 -0800 (PST)
USER:HELO host.example.com
SERVER:250 mail.example.net Hello host.example.com [192.0.2.1], pleased to meet you
USER:MAIL FROM:<user@example.com>
SERVER:250 2.1.0 <user@example.com>... Sender ok
USER:RCPT TO:<postmaster@example.net>
SERVER:250 2.1.5 <postmaster@example.net>... Recipient ok
USER:DATA
SERVER:354 Enter mail, end with "." on a line by itself
USER:This is a test message
USER:.
SERVER:250 2.0.0 k2FApLlB020139 Message accepted for delivery
USER:QUIT
SERVER:221 2.0.0 mail.example.net closing connection
USER:HELO host.example.com
SERVER:250 mail.example.net Hello host.example.com [192.0.2.1], pleased to meet you
USER:MAIL FROM:<user@example.com>
SERVER:250 2.1.0 <user@example.com>... Sender ok
USER:RCPT TO:<postmaster@example.net>
SERVER:250 2.1.5 <postmaster@example.net>... Recipient ok
USER:DATA
SERVER:354 Enter mail, end with "." on a line by itself
USER:This is a test message
USER:.
SERVER:250 2.0.0 k2FApLlB020139 Message accepted for delivery
USER:QUIT
SERVER:221 2.0.0 mail.example.net closing connection
Mail log
Sendmail uses the mail facility of syslog for logging. The mail log is usually written to /var/log/maillog
Sendmail configuration files
- /etc/mail/local-host-names
Add the domains (one per line) for which you want mail to be delivered locally to this file.
- /etc/mail/relay-domains
If the system is acting as a secondary MX server, add the domains (one per line) to this file.
- /etc/mail/aliases
Add your aliases to this file, then run newaliases to update the data base.
- /etc/mail/access
This file is used to allow or disallow relaying. The configuration section explains howto run makemap to update the data base.
File and directory permissions
The following permissions are generally required for sendmail related files and directories:
-r-xr-sr-x root smmsp /usr/sbin/sendmail
drwxrwx--- smmsp smmsp /var/spool/clientmqueue
drwx------ root wheel /var/spool/mqueue
-r--r--r-- root wheel /etc/mail/sendmail.cf
-r--r--r-- root wheel /etc/mail/submit.cf
drwxrwx--- smmsp smmsp /var/spool/clientmqueue
drwx------ root wheel /var/spool/mqueue
-r--r--r-- root wheel /etc/mail/sendmail.cf
-r--r--r-- root wheel /etc/mail/submit.cf
Mail relaying
Mail relaying occurs when mail is forwarded from someone else through your mail server. Forwarding mail through a mail server is perfectly natural as long as either the originator of the message or the receiver is a authorized user. If neither the sender nor the recipient of the message is a local user, it is called third-party mail relaying.
Mail servers should be configured not to accept third-party mail relay. If a mail server allows third-party mail relaying from everyone, it is known as an open relay. Such a mail server attracts spammers as it can be used to send large amounts of junk mail under false identity.
If the client computer from which you are connecting from has a static IP address, you can add the following entry, for example, to allowing relaying (send mail):
192.168.0.5 <TAB> RELAY (allows 192.168.0.5 to relay)
192.168.1 <TAB> RELAY (allows 192.168.1/24 to relay)
You should run the makemap command after modifying the access file.
If you are connecting from a dynamic IP address, you should use SMTP AUTH to allow relaying.
Mail submission
Sendmail has been split into two parts, with one part handling mail submission. This allows sendmail to run without being SUID root.
The Mail Submission Program (MSP) uses the /var/spool/clientmqueue directory by default. It will use the /etc/mail/submit.cf configuration file. That configuration file can be generated from the submit.mc using m4.
The MSP will send outgoing mail by passing it to localhost on port 25 using the SMTP protocol. As of sendmail version 8.12.x, you should have sendmail running as a daemon and listening on localhost at least.
Submitting mail from the command line with sendmail
Type the following command where user@example.com is the address of the recipient:
/usr/sbin/sendmail user@example.com
Type in your message, then press Enter and type in a dot and press Enter again.
Piping to sendmail
You can pipe in a message to sendmail with the following command where filename is name of the file containing the message:
/usr/sbin/sendmail user@example.com < filename
Sending file attachments
Sendmail does not send mail attachments. You should encode your file using a MIME encoding utility before piping it to sendmail.
The future
Sendmail X was slated as the next version after sendmail 8. It is not longer being developed. Its successor is MeTA1.
Acronyms
LDA Local Delivery Agent a program that a mail server uses to deliver mail messages to the mailboxes of users. This program is also known as local mailer (e.g. mail, procmail).
MUA Mail User Agent a program that a user uses to process mail messages (e.g. MS Outlook, Eudora, Pine, Mutt).
MTA Mail Transfert Agent a program that a mail server uses to send and receive mail messages using SMTP (e.g. sendmail).
MSA Mail Submission Agent.
MSP Mail Submission Program.
SMTP Simple Mail Transfer Protocol
For More info visit the below link :
http://www.wikihow.com/Configure-Sendmail
For More info visit the below link :
http://www.wikihow.com/Configure-Sendmail
No comments:
Post a Comment