CertCities.com -- The Ultimate Site for Certified IT Professionals
Register today for a Free Sponsored Tech Library Webcast and you could WIN! Share share | bookmark | e-mail
  Microsoft®
  Cisco®
  Security
  Oracle®
  A+/Network+"
  Linux/Unix
  More Certs
  Newsletters
  Salary Surveys
  Forums
  News
  Exam Reviews
  Tips
  Columns
  Features
  PopQuiz
  RSS Feeds
  Press Releases
  Contributors
  About Us
  Search
 

Advanced Search
  Free Newsletter
  Sign-up for the #1 Weekly IT
Certification News
and Advice.
Subscribe to CertCities.com Free Weekly E-mail Newsletter
CertCities.com

See What's New on
Redmondmag.com!

Cover Story: IE8: Behind the 8 Ball

Tech-Ed: Let's (Third) Party!

A Secure Leap into the Cloud

Windows Mobile's New Moves

SQL Speed Secrets


CertCities.com
Let us know what you
think! E-mail us at:



 
 
...Home ... Editorial ... Columns ..Column Story Saturday: April 5, 2014


 Inside the Kernel  
Emmett Dulaney
Emmett Dulaney


 Sendmail Simplified
Take better advantage of of your Linux system's mail server capabilities by brushing up on sendmail.
by Emmett Dulaney  
3/26/2008 -- One of the things that Linux excels at is functioning as a mail server. To set up your system as a mail server, you must configure the sendmail mail transport agent properly. The problem is that sendmail has a reputation for being a complete but complex mail-delivery system; just one look at sendmail's configuration file -- /etc/mail/sendmail.cf in Fedora and /etc/sendmail.cf in SuSE -- can convince you of the latter.

Luckily, you don't have to be an expert on the sendmail configuration file. All you need is one of the predefined configuration files -- like the one that's installed on your system -- to use sendmail.

Your system already has a working sendmail configuration file: /etc/mail/sendmail.cf. The default file assumes you have an Internet connection and a name server. Provided that you have an Internet connection and that your system has an official domain name, you can send and receive e-mail from your Linux PC.

To try out the sendmail mail transfer agent, you can use the mail command to compose and send a message to any user account on your Linux system. As a test, compose a message and send it to yourself. For example, here's how to send a message using the mail command (input appears in boldface):

mail edulaney
Subject: Testing e-mail
This is from my Linux system.

The mail command is a simple mail user agent. In the above example, the addressee (edulaney) is specified in the command line. The mail program prompts for a subject line. Following the subject, enter the message and end it with a line that contains only a period. You'll be prompted for a "Cc" but leave that blank. After ending the message, the mail user agent passes the message to sendmail (the mail transport agent) for delivery to the specified address. Sendmail delivers the mail message immediately. To verify the delivery of mail, type mail to run the mail command again and read the message.

Thus, the initial sendmail configuration file is adequate for sending and receiving e-mail, at least within your Linux system. External mail delivery also works, provided that your Linux system has an Internet connection and a registered domain name.

The Delivery Mechanism
On an Internet host, the sendmail mail transport agent delivers mail using the Simple Mail Transfer Protocol (SMTP). SMTP-based mail transport agents listen to the TCP port 25 and use a small set of text commands to exchange information with other mail transport agents. In fact, SMTP commands are simple enough that you can use them manually from a terminal to send a mail message. When used, the telnet command opens a TELNET session to port 25 (the port on which sendmail expects SMTP commands). The sendmail process on the Linux system immediately replies with an announcement.

You can type HELP to view a list of SMTP commands. To get help on a specific command, type HELP commandname. Type HELO localhost to initiate a session with the host. The sendmail process replies with a greeting. To send the mail message, start with the MAIL FROM: command that specifies the sender of the message. Next, use the RCPT TO: command to specify the recipient of the message. If you want to send the message to several recipients, provide each recipient's address with the RCPT TO: command.

To enter the mail message, use the DATA command. In response to the DATA command, sendmail will instruct you to end the message with a period on a line by itself. After doing this, the sendmail process displays a message indicating that the message is accepted for delivery. You can then quit the sendmail session with the QUIT command.

The Configuration File
You don't have to understand everything in the sendmail configuration file, sendmail.cf, but you need to know how that file is created. That way, you can make minor changes if necessary and regenerate the sendmail.cf file. The sendmail.cf file's syntax is designed to be easy to parse by the sendmail program because sendmail reads this file whenever it starts. Human readability wasn't a primary consideration when the file's syntax was designed. Still, with a little instruction, you'll be able to understand the meaning of the control lines in sendmail.cf.

Each sendmail control line begins with a single-letter operator that defines the meaning of the rest of the line. A line that begins with a space or a tab is considered a continuation of the previous line. Blank lines and lines beginning with a pound sign (#) are comments.

Often, there's no space between the single-letter operator and the arguments that follow the operator, which makes the lines even harder to understand. For example, sendmail.cf uses the concept of a class -- essentially a collection of phrases. You can define a class named P and add the phrase REDIRECT to that class with the following control line:

CPREDIRECT

Because everything is jumbled together, the command is hard to decipher. On the other hand, to define a class named Accept and set it to the values OK and RELAY, write the following:

C{Accept}OK RELAY

This command may be slightly easier to understand because the delimiters (such as the class name, Accept) are enclosed in curly brackets.

Other more recent control lines are even easier to understand. For example, the line

O HelpFile=/etc/mail/helpfile

defines the option HelpFile as the filename /etc/mail/helpfile. That file contains help information sendmail uses when it receives a HELP command.

This table summarizes the one-letter control operators used in sendmail.cf. Each entry also shows an example of that operator. The table should help you understand some of the lines in sendmail.cf.

If you make changes to the /etc/mail/sendmail.mc file, you must generate the /etc/mail/sendmail.cf file by running the sendmail.mc file through the m4 macro processor with the following command (you have to log in as root):

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf


Emmett Dulaney is the author of several books on Linux, Unix and certification. He can be reached at .

 


More articles by Emmett Dulaney:

-- advertisement --


There are 13 CertCities.com user Comments for “Sendmail Simplified”
Page 1 of 2
3/29/10: None from None says: http://www.aol.com, http://www.yahoo.com, http://www.bing.com, http://www.pullsdegro.com, http://www.msn.com,
7/1/13: louisvuittonttoutlet.com from [email protected] says: good share. louisvuittonttoutlet.com http://www.louisvuittonttoutlet.com
7/5/13: gucci outlet store from [email protected] says: ths gucci outlet store http://www.guccioutletstore-online.com
7/23/13: OakleyFrogskinsSungl from [email protected] says: sunglass is given free supercharge... from a social concept company! Oakley Frogskins Sunglasses http://www.replica-oakleysunglassesusa.com
7/23/13: toms sale from [email protected] says: A shoes all the partners is raving about toms sale http://www.tomsoutlets-usa.com
7/26/13: Herve Leger uk from [email protected] says: nice articles Herve Leger uk http://www.herveleger-outlet.co.uk/
8/18/13: OakleySunglassesOutl from [email protected] says: Own a sunglass With no need of Putting in A Single Pound Oakley Sunglasses Outlet http://www.replica-oakleysunglassesusa.com
8/30/13: nfl custom jerseys from [email protected] says: nice articles nfl custom jerseys http://www.customnflljerseys.com
9/5/13: nfl custom jersey from [email protected] says: good articles nfl custom jersey http://www.customnflljerseys.com
9/8/13: ugg from [email protected] says: thank you for share! ugg http://www.uggrsale.eu
First Page   Next Page   Last Page
Your comment about: “Sendmail Simplified”
Name: (optional)
Location: (optional)
E-mail Address: (optional)
Comment:
   

-- advertisement (story continued below) --

top