Suresh Ramasubramanian |
|||
Sendmail on a dialup |
There are several howtos around to configure sendmail, but most of them give rather sketchy information on how to configure sendmail on a dialup. Here's a short howto, updated from Bhyrava Prasad's howto, which shows you how to do it by editing sendmail.cf.
This is, however, a bit error prone as a small slip can render you with an unusable .cf file which has to be restored from backups. Direct editing of sendmail.cf is strongly discouraged in newer versions of sendmail, which urge you to [re]build sendmail.cf using m4 macros
This is a rewritten (and cleaned up) version of a post I made to comp.mail.sendmail some days ago
I'm assuming sendmail 8.10.x or above here (which is there in the latest releases of most linuxes - RedHat 7, Mandrake 7.2, Slackware 7.1 etc). If you don't have it, you can download an updated RPM (or better still, download the tarball from ftp.sendmail.org and build it - it's easy).
One major difference in 8.10 and above is that all config files have moved to /etc/mail - the aliases file, sendmail.cf, virtusertable, mailertable etc. For more information, click here to read all about sendmail 8.10 at Sendmail.Net
1. Stop sendmail if it's already running
mjollnir# /etc/rc.d/init.d/sendmail stop
2. Install the sendmail-cf-[your-version-number].rpm if you are using an RPM build of sendmail. If you are using a compiled version, you don't need to install anything else - it's all there :)
3. Edit this file below (most importantly, put your ISP's smtp, that is, outgoing mail, server in place of your.isps.smtp.server. Then replace the domain name you want sendmail to call itself as (say vsnl.com or yahoo.com - whatever your primary e-mail account is). Save this file below as /etc/mail/sendmail.mc and follow the instructions given in the .mc file's comments if you use (oh, before I forget, BACKUP FIRST) to generate /etc/mail/sendmail.cf.
Note: If you use the sendmail 8.11 RPM that comes with Redhat 7.x, there is something you have to look out for (more details later on in this howto).
sendmail.mc file for use on dialups
divert(-1) dnl This is the macro config file used to generate the /etc/sendmail.cf dnl file. If you modify this file you will have to regenerate the dnl /etc/sendmail.cf by running this macro config through the m4 dnl preprocessor: dnl dnl m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf dnl dnl You will need to have the sendmail-cf package installed for this to dnl work if you use an rpm build of sendmail dnl dnl include(`../m4/cf.m4') dnl dnl If you compile sendmail from a tarball, use the include above. dnl In this setup, you should create the file as cf/cf/config.mc dnl (in the sendmail source tree: eg. /usr/src/sendmail-8.11.2/cf/cf dnl Now give the command "sh Build config.cf". Now copy the file dnl config.cf as /etc/mail/sendmail.cf (remember to backup first&) dnl dnl If you are using the RPM build of sendmail, use the dnl include statement given below instead dnl include(`/usr/lib/sendmail-cf/m4/cf.m4') define(`confDEF_USER_ID',``8:12'') OSTYPE(`linux') undefine(`UUCP_RELAY') undefine(`BITNET_RELAY') define(`confCF_VERSION',`dialup-1.3') define(`SMART_HOST', `your.isps.smtp.server') define(`confAUTO_REBUILD') define(`confTO_CONNECT', `1m') define(`confTO_IDENT',0) define(`confTRY_NULL_MX_LIST',true) define(`confDONT_PROBE_INTERFACES',true) define(`confCON_EXPENSIVE',true) define(`confDELIVERY_MODE', `queued') define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail') define(`ALIAS_FILE',`/etc/mail/aliases') MASQUERADE_AS(`example.com') FEATURE(`masquerade_envelope') FEATURE(`smrsh',`/usr/sbin/smrsh') FEATURE(`mailertable',`hash -o /etc/mail/mailertable') FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable') FEATURE(redirect) FEATURE(always_add_domain) FEATURE(use_cw_file) FEATURE(`use_ct_file') FEATURE(local_procmail) MAILER(smtp) MAILER(procmail) FEATURE(`access_db') FEATURE(`blacklist_recipients') FEATURE(`accept_unresolvable_domains') FEATURE(`accept_unqualified_senders') dnl FEATURE(`relay_based_on_MX')
Notes on just what all the arcane stuff below means can be found in the file cf/README in the sendmail source tree (or in /usr/doc/sendmail if you install the sendmail-docs-[your-version-number].rpm
Note the quoting used - `' (the opening quote is a backtick and the closing quote is a single quote mark). Another thing you ought to remember is that the comment string in sendmail.mc is "dnl" and not # or /* */.
4. Now we'll ask sendmail not to do DNS lookups when passing all mail to the
smarthost for delivery. Create a file called /etc/mail/service.switch
hosts files aliases files
5. There's a FEATURE defined above called use_ct_file. This is a list of "trusted" users whom sendmail allows to change the envelope sender from, say, login-name@your-domain.com to cute_cat@example.com, say, without any objections. Or else, sendmail will set the sender, but add an ugly looking header like
X-Authentication-Warning: localhost.localdomain: suresh set sender to suresh@example.com using -f
So, after including the use_ct_file feature, create a file
/etc/mail/trusted-users (sendmail.ct in 8.9.x and older) and put all the login
names you use / want to trust on that machine (in case you have more than one)
into that file, one login name per line.
For example:
suresh hserus
6. Restart sendmail
mjollnir# /etc/rc.d/init.d/sendmail restart
Phew! Done. :)
Try this howto as well - Demand Dialing and Sendmail
Another approach to configuring sendmail on a dialup is described in this post to comp.mail.sendmail by Andrzej Filip. It requires sendmail 8.10.x or above with the dsmtp mailer.
If you want an even easier way out, download Donncha O'Caoimh's script from the website of the Cork LUG, Ireland and enjoy life :)
Finally, if you have any problems with sendmail, do the following
We now have a sendmail system that queues mail sent to non local addresses for delivery through a smarthost (say your ISP's smtp server).
Dr. Grahame Cooper writes:
You say that "One major difference in 8.10 and above is that all config files have moved to /etc/mail - the aliases file, sendmail.cf, virtusertable, mailertable etc.". Unfortunately, the sendmail rpm that comes with Redhat 7.0 still puts alias and sendmail.cf into the /etc directory, which can cause problems for people with this distribution who (like me) just copy and paste your sample sendmail.mc file.
Thanks for the tip :)
So, if you run Redhat 7, make appropriate changes to the paths, and copy the generated sendmail.cf into /etc. Or better, download and compile the official sendmail.org version.
Please note that if you turn off DNS in the service.switch file, you _have_ to use a smarthost for relaying outbound mails, by using the macro definition define(`SMART_HOST',`your.isps.smtp.server') as above.
This is because as DNS lookups are turned off at this stage, sendmail will deliver mail using gethostbyname() (directly to the hostname in the email address). The problem arises when the main host and the mailserver are not on the same IP / same machine.
For example, a domain example.com might be on 10.0.3.100 but its MX (or Mail eXchanger) server, which receives mail for the domain example.com, might be mail.example.com, which happens to be at 10.0.3.20
If you turn off DNS lookups locally and try to send mail directly (without a smarthost), mail meant for example.com will go directly to example.com instead of mail.example.com, and so may not reach the intended account, or even bounce with a "Relaying Denied" error.