[LinuxFocus-icon]
<--  | Home  | Map  | Index  | Search

News | Archives | Links | About LF
This document is available in: English  Castellano  Deutsch  Francais  Nederlands  Turkce  

Stefan Blechschmidt
by Stefan Blechschmidt
<sb(at)sbsbavaria.de>

About the author:

Being a trained electrician, I found myself in 1990 in front of a CAD workstation to develop a switch and control station. Obviously, I got infected by a then unknown 'virus', and that's just fine.



Translated to English by:
Jürgen Pohl <sept.sapins(at)verizon.net>

Content:

 

Automail for fli4l

Automail mit fli4l

Abstract:

Who is not using this one diskette router from http://www.fli4l.de/ ? Most likely everyone of its users knows about the problem when the router is being used in dial-on-demand mode in an existing network system with internal mail server. When the router establishes a connection the mail server should know about it, this would enable it to send and receive mail.
This article is describing one possibility on how to solve this problem.


_________________ _________________ _________________

 

Short Description of the Environment

Our illustration shows the concept of the network which we are going to use as a example for this article. WS1 to WS3 represent workstations connected to the WWW through the router. The service-host is responsible for the internal and the external mail. Sending mail is being handled by MTA. Receiving with fetchmail and subsequent sorting with procmail. The mailboxes on the service host are provided to the workstations via POP3 or IMAP

 

The Problem

If one of the workstations is establishing a connection to the WWW the service host does normally not notice it. It would be possible to instruct the service host with the help of a cron job to send or receive mail at specific times. More elegant would be to inform the service host when the connection is being established, enabling it to do the mail job.

Since the router is being run from a diskette, there is no complex script or program to control the mail server from the router.

 

The Idea

While informing the service host about the connection, it should be possible to launch a request to start a process for mail to be sent or received.

 

The Solution

For fli4l a program named wget is available , with the size of about 100 kB, it should fit easily on the diskette. With wget we can establish a connection to the service host at the same time when dialing. This will be possible by inetd opening a port on the service host, waiting for a connection from the router. With the connection a script will start additional processes to send and receive mail.

The script is written in Perl you may download it here (mailstart.pl.gz).

 

Router Adjustments

Dialing in activates the file .../opt/etc/ppp/ip-up. This is the right place to establish a connection to our service host. By adding the line:

wget -t 1 --spider MAILSERVER:PORT/xyz &> /dev/null

we are doing just that.

Explanations to the Commands of wget

 

Mail Server Adjustment

With the help of the super server inetd the program mailstart [1] is being activated. To make this happen we have to edit the files

/etc/inetd.conf

/etc/services

In this file we assign the port which wget shall access. The line:

mailstart  4000/tcp # Mailstart

does accomplish that.

/etc/inetd.conf

In this file we are defining which program should be started. inetd monitors its execution and logs this in /var/log/syslog.

The line:

mailstart  stream  tcp  nowait  root  /usr/sbin/tcpd  /root/bin/mailstart

is going to finish this step. The first name must be the same as noted in the file /etc/services.

 

Adjustments mailstart.pl

Through variables the program can be adjusted to the particular server.

$protokoll

With the variable $protokoll we can define if the calls shall be logged. Setting the variable to 1 will log the calls in /var/log/mailstart.log. If the variable is set to 0 no log will be created.

Default: 1 create log

$protokoll_ziel

With this variable we can determine the target of the log.

Default: /var/log/mailstart.log

$mailholen

Here we enter the name of the program which fetches the mail. To start that program the user must be root or the name which was entered into /etc/inetd.conf. If someone else wants to use the program the command has to start with su USER -c \"COMMAND PARAMETER\" . If the command is several words long it has to be set in quotation marks, also, it must be protected with \.

Default (one line):

su postmaster -c \"fetchmail -t 40 -a -L /var/log/fetchmail/fetchmail.log -f /home/postmaster/.fetchmailrc\"

$mailsenden

Here is the place for the program used to send email. To start that program the user must be root or the name which was entered into /etc/inetd.conf If someone else wants to use the program the command has to start with su USER -c \"BEFEHL PARAMETER\". If the command is several words long it has to be set in quotation marks, the command must be protected with \.

Default: sendmail -q

By the way, part of the program is a small POD documentation which provides a short description. You can get to the description with perdoc mailstart.

 

Test

Prior to testing the super server needs to be restarted, /etc/init.d/inetd restart should do it. Now you can test with telnet localhost mailstart if the server responds . You should get a display similar to this.

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.1 220 OK
Date: Sun, 20 Jul 2003 10:45:46 GMT
Server: mailstart/perl (sbsbavaria)
Last-Modified: Sun, 20 Jul 2003 10:45:46 GMT
Content-Type: text/txt
Content-Length: 11
1234567890
Connection closed by foreign host.

Well, that's it. I hope you are getting the desired result from my description. If that's not the case we do have a problem.
- You, because it doesn't work.
- I, because I was not able to give a decent description:-).

 

Download

 

Links / References

 

Talkback form for this article

Every article has its own talkback page. On this page you can submit a comment or look at comments from other readers:
 talkback page 

<--, back to the index of this issue

Webpages maintained by the LinuxFocus Editor team
© Stefan Blechschmidt, FDL
LinuxFocus.org
Translation information:
de --> -- : Stefan Blechschmidt <sb(at)sbsbavaria.de>
de --> en: Jürgen Pohl <sept.sapins(at)verizon.net>

2003-09-27, generated by lfparser version 2.38

mirror server hosted at Truenetwork, Russian Federation.