SuSE GmbH

SuSE Support Database

Title: sendmail: Offline-SMTP Howto send mails to your provider

----------

Mainpage o Searchform o History o Versions o Categories o Contents
Deutsch

----------

sendmail: Offline-SMTP Howto send mails to your provider

Applies to

SuSE Linux: Version 5.0

Question:

How to deliver mails via sendmail and the SMTP protocol?

Solution:

This solution is designed for dial up connections via ISDN or modem, respectively. The local machine is not known to the provider which normally is the case with dynamic IPs.

Any unecessary connect should be avoided. This is achieved by queuing the mails first and let them be delivered afterwards. First you should edit the sendmail startup script in /sbin/init.d/sendmail and remove the parameter "-q30m". If this parameter exists the queue will be emptied every 30 minutes.

First you should create a m4 which serves as a template for sendmail. Create a file /etc/sendmail.config/cf/linux.smtp-off.mc:

include(`../m4/cf.m4')
VERSIONID(`linux for smtp-only(offline) setup')dnl
OSTYPE(linux)dnl
define(`confDEF_USER_ID', `daemon:daemon')dnl
define(`confTRUSTED_USERS', `uucp mdom wwwrun')dnl
define(`QUEUE_DIR', `/var/mqueue')dnl
define(`PROCMAIL_MAILER_PATH', `/usr/bin/procmail')dnl
define(`confSERVICE_SWITCH_FILE',`/etc/service.switch')dnl
define(`confUSERDB_SPEC',`/etc/userdb.db')dnl
define(`confHOSTS_FILE',`/etc/hosts')dnl
define(`confSAFE_QUEUE',`True')dnl
define(`confCON_EXPENSIVE',`True')dnl
define(`SMTP_MAILER_FLAGS',`e')dnl
FEATURE(local_procmail)dnl
FEATURE(nocanonify)dnl
FEATURE(nouucp)dnl
FEATURE(nodns)dnl
FEATURE(always_add_domain)dnl
FEATURE(masquerade_envelope)dnl
MAILER(local)dnl
MAILER(procmail)dnl
MAILER(smtp)dnl
For a detailed description of the entries please have a look at the sendmail documentation. Here we only mention some of them roughly:

Next the file /etc/service.switch should be created (see entry sendmail using SMTP but no DNS:

hosts   files
aliases files

The next step is to create a database which allocates email addresses to local users. There are two lines a user:

Loginname:mailname email address
email adress:maildrop Loginname
Example:
anna:mailname anna.sampleuser@provider.de
anna.sampleuser@provider.de:maildrop anna

Now you are able to generate the configuration files, or to convert them into a format readable by sendmail, respectively.
Here comes the template for the sendmail configuration file. Since this procedure will overwrite the SMTP template from the sendmail package it is recommended to save it first!

mv /etc/sendmail.smtp.cf /etc/sendmail.smtp.cf.CDROM
thereafter create a new template:
cd /etc/sendmail.config/cf
m4 < linux.smtp-off.mc > /etc/sendmail.smtp.cf
Now we have to deal with the user database (UserDB):
makemap btree /etc/userdb.db < /etc/userdb
Now we do have a template. All additional work may be done with YaST. Invoke YaST and choose
Administering the system ->
        change configuration file
There are some variables to control sendmails behaviour: The schedule (= und ") is of course not set by YaST.

Well, that's all as far as configuration is concerned. You only need to restart sendmail.

/sbin/init.d/sendmail stop
/sbin/init.d/sendmail start

Of course you need to test your configuration.
We just start a test:

/usr/sbin/sendmail -bv anna.sampleuser@provider.de
The result should resemble
anna.sampleuser@provider.de... deliverable: mailer relay, host mail.provider.de,user anna.sampleuser@provider.de
If this ran smoothly you may risk a first run. First just use a "tiny" mail agent as mail or mailx We just send a uname -a. Start being the user given in the Userdb. Just send a mail to your account:
uname -a | mailx -s TEST anna.sampleuser@provider.de
Now two files in /var/mqueue will be created by sendmail. There is one starting with df that contains the message body ( in this case the output of uname -a. The second file starting with qf contains the header information. Here the following lines are of interest:
$_anna@localhost
Sanna
RPFD:anna.sampleuser@provider.de
H?P?Return-Path: <anna.sampleuser@provider.de>
H?F?From: "Anna M." <anna.sampleuser@provider.de>
HTo: anna.sampleuser@provider.de
Now the mail (or even more) may be send:
sendmail -q
There are two logfiles that contain information on how (or if) the message(s) was sent: /var/log/mail and /var/log/messages. The mail may now be fetched by fetchmail.

Specialities

Be aware that this stupid tool (mail) is not very useful for mailing as it changes the mail header and adds a return path which contains the local login and hostname. To avoid this just use a mature mail program as pine (e.g.). They are able to hand the correct information to sendmail and everything will run smoothly.

For certain mail agents (e.g. pine) you have to tell not to change the header ( the From line). There is an alternative. Just enter the users listed in the Userdb as "trusted". This might be done in the m4 makro in confTRUSTED_USERS or in /etc/sendmail.smtp.cf.

#####################
#   Trusted users   #
#####################

# this is equivalent to setting class "t"
#Ft/etc/sendmail.ct
Troot
Tdaemon
Tuucp mdom wwwrun
Tanna
There is no sense in changing the sendmail configuration file /etc/sendmail.cf as this will be (re)created with each run of YaST or SuSEconfig respectively.
So, if you want to change (hack) something manually you are advised to do so in /etc/sendmail.smtp.cf for SMTP or in /etc/sendmail.uucp.cf for UUCP respectively.

Hint:

Always use tabstops instead of blanks (e.g. in /etc/service.switch) for separating the columns.

----------

See also:

----------

Keywords: MAIL, SENDMAIL, SMTP, OFFLINE

----------

Categories: Linux , Email

----------

Feedback welcome: Send Mail to mt@suse.de (Please give the following subject: SDB-smt_sendmail)

----------

Mainpage o Searchform o History o Versions o Categories o Contents
Deutsch

----------

SDB-smt_sendmail, Copyright SuSE GmbH, Nuremberg, Germany - Version: 22. Aug 1997
SuSE GmbH - Last generated: 07. Oct 1999 18:04:33 by maddin with sdb_gen 1.00.0