| Home » E-mail » Sendmail |
Sendmail
Sendmail is installed and given a minimal configuration out-of-the-box on most distributions of Linux and BSD. Unfortunately, the default configuration usually isn't appropriate for a home user with a dial-up connection. In this demonstration I will walk through the changes that will have to be made for your sendmail to work properly with the provided SMTP servers.
Sendmail takes the mail message from you, and delivers it to the next mail server on the way to the message's destination. It will not provide an interface for message composition, and it will not retrieve stored messages from your mail box on the POP server. For message composition, you will need a mail user application such as mutt or pine. For retrieving mail from the AT&T Worldnet Service POP3 servers, see the WURD article on Fetchmail.
If you don't have sendmail, you may downloaded the source from sendmail.org. Installation is well covered in the accompanying documentation, and will not be repeated here.
You will also need the m4 macro program on your system to make the config files
Submitted by: Carl Tucker
Note: You will need to find your AT&T Worldnet Service account information.
Locating your configuration files
When sendmail starts, it reads its configuration from /etc/mail/sendmail.cf (older versions, from /etc/sendmail.cf). If you page through sendmail.cf, you'll find that it's extremely cryptic. It's also very intolerant of mistakes. Fortunately, there's an easier way to make this file.
The sendmail sources come with m4 macros to read a file, and build a sendmail.cf file from it. We'll make such a file.
Locate your sendmail directory. On my system, this is /usr/share/sendmail. If you have the full source code for sendmail, this directory will have all the source code and makefiles for building sendmail. The important part for us is the subdirectory cf. That's what you're looking for, a directory called sendmail with a subdirectory called cf. I'll refer to directories relative to this, i.e.:
/usr/share/sendmail/cf/cf/generic.mc = cf/cf/generic.mc.
Making a .cf file with m4
Change to the cf/cf/ directory and take a look. There should be several files called generic-something.mc, where 'something' is the operating system it's for. Copy the appropriate one to a new file in the same directory. Name it something that means something to you. My machine is named bullwinkle.local, and it's a FreeBSD system, so I did the following:
% cp generic-bsd4.4.mc bullwinkle.mc
We're going to be editing the new file for our new configuration. First, though, let's make sure we get the basics down. Make a .cf file from the new .mc file, using the m4 macros:
% m4 ../m4/cf.m4 bullwinkle.mc > bullwinkle.cf
The ../m4/cf.m4 preloads the macros for sendmail .cf-file building. If all goes well, you should then have a generic bullwinkle.cf file.
Setting a smart host
The first configuration we need to change is the option for a smart host. A smart host handles all of your outgoing (to the Internet) mail. Since AT&T Worldnet Service blocks outgoing SMTP connections by default, and many domains refuse mail from dialups anyway, we will use AT&T Worldnet's mail server as a smart host.
Find the line inbullwinkle.mc that says DOMAIN(generic). Following that line, add this new line:
define(`SMART_HOST', `mailhost.worldnet.att.net')
Be careful with the quoting: the left hand quotes are made with the backquote key, and the right hand quotes are the normal single quote.
When our config file is made, this line is going to tell sendmail to send all non-local mail to mailhost.worldnet.att.net, which is what we want.
Setting up the genericstable
At this point, our configuration file would get our mail delivered. There is one other problem we have to fix, though: when we send mail, the headers on the mail have our local machine names. My mail would appear to be from cft@bullwinkle.local, not from flestrin@worldnet.att.net, which will make it difficult for anyone to reply.
The solution to this involves using the genericstable feature of sendmail, which rewrites sender addresses on mail it handles.
Add these lines to bullwinkle.mc after the SMART_HOST line:
FEATURE(genericstable)
FEATURE(masquerade_envelope)
GENERICS_DOMAIN(bullwinkle)
GENERICS_DOMAIN(bullwinkle.local)
Change the 'bullwinkle' and 'bullwinkle.local' to values appropriate for your setup, basically, the machine name, and the full machine name with domain.
Now create a file,/etc/mail/genericstable. In that file, you put how you want addresses rewritten. Mine looks like this:
cft@bullwinkle.local flestrin@worldnet.att.net
cft@bullwinkle flestrin@worldnet.att.net
cft flestrin@worldnet.att.net
Where cft is my login name on this machine, bullwinkle.local is the machine, and flestrin@worldnet.att.net is what I want the address to look like after rewriting.
After that file is in place, make it into a .db file:
% makemap hash /etc/mail/genericstable.db < /etc/mail/genericstable
Queuing or Sending?
The next step involves a decision. Do you want sendmail to attempt delivery right away, even if you're not online, or to hold your mail in the queue until the next time you connect?
Holding mail in the queue will prevent sendmail from bouncing your mail if you attempt to send while you don't have a connection. If you want sendmail to hold your mail until you have a connection, add the following lines to bullwinkle.cf after the ones we just added:
define(`confCON_EXPENSIVE', `True')
define(SMTP_MAILER_FLAGS, e)
define(`confTO_QUEUEWARN', `12h')
The first of these lines tells sendmail that, if it selects a delivery method marked expensive, then it should hold the mail for later. The next line marks the SMTP method as expensive. The third line sets the timeout for warning you when mail has been waiting for delivery to 12 hours. 12 hours is long enough for me to get a chance to connect and deliver mail before I get a warning from sendmail. You can adjust this however you like. The default is 4 hours.
If you do tell sendmail to hold mail in the queue instead of delivering it, make sure your sendmail starts with the -q flag. Mine starts with sendmail -bd -q15m, which tells sendmail to try delivering the queue every 15 minutes. If I'm not online, it waits until next time. You can force sendmail to try delivery immediately by the command line:
% sendmail -q/p>
The completed file
After all the adjustments we've made, my bullwinkle.mc looks like this:
divert(-1)
#
# Copyright (c) 1998, 1999 Sendmail, Inc. and its suppliers.
# All rights reserved.
# Copyright (c) 1983 Eric P. Allman. All rights reserved.
# Copyright (c) 1988, 1993
# The Regents of the University of California.
# All rights reserved.
divert(0)dnl
VERSIONID(`$Id: article.html,v 1.4 2002/02/17 12:08:18 cft Exp $')
OSTYPE(bsd4.4)dnl
DOMAIN(generic)dnl
define(`SMART_HOST', `mailhost.worldnet.att.net')
FEATURE(genericstable)
FEATURE(masquerade_envelope)
GENERICS_DOMAIN(bullwinkle)
GENERICS_DOMAIN(bullwinkle.local)
define(`confCON_EXPENSIVE', `True')
define(SMTP_MAILER_FLAGS, e)
define(`confTO_QUEUEWARN', `16h')
MAILER(local)dnl
MAILER(smtp)dnl
Now make it into a .cf file:
% m4 ../m4/cf.m4 bullwinkle.mc > bullwinkle.cf
You should have a new bullwinkle.cf file. Back up your current /etc/mail/sendmail.cf, then
% cp bullwinkle.cf /etc/mail/sendmail.cf
Now kill and restart sendmail however your operating system does it, or simply reboot and let it start itself. Send yourself a test message to your '@worldnet.att.net' address. When you receive it, reply to that message to make sure the return addresses are correct.
See also:
Sendmail and dial-up modem Internet by Wouter Hanegraaff
Need Additional Help?
If you can't find the answers you need, please try:
- The help file for the application you are using.
- Our FAQs.
- The AT&T Worldnet Help Newsgroups.
