If your qmail system is a hub host for remote systems that connect intermittently by dialup, it is straightforward but messy to deliver the mail while the remote systems are connected. One approach is to create a flag file in a known directory when a host connects and delete the file when the host disconnects. Then run a script periodically from cron that loops over all of the flag files to push out mail to currently connected hosts. To flesh out this example, assume there are three dialup hosts called red.example.com, blue.example.com, and green.example.com. Create virtualdomains that give them different virtual domain prefixes: red.example.com:alias-dial-red blue.example.com:alias-dial-blue green.example.com:alias-dial-green You can put all of the alias-dial mail into one Maildir since the Delivered-To: prefixes keep them separate. To put all the mail for the three hosts into ~alias/dialmail/, create ~alias/.qmail-dial-default containing the line ./dialmail/. To track the currently connected hosts, put the flag files into ~alias/dialflags and have the dialup connection script create a file with the host's simple name (red, blue, or green) in that directory containing the host's current IP address. Then run this script from cron to push out the mail to whichever hosts are currently connected: #!/bin/sh # run this every 15 minutes from cron to push out the mail cd /var/qmail/alias/dialflags for hn in * do ip=$(cat $hn) # IP address in the flag file setlock ../$hn.lock \ # lock deliveries to this host maildirsmtp /var/qmail/alias/dialmail \ alias-dial-$hn- $ip my.example.com 2>&1 | splogger serial done If you also want to push out any waiting mail as soon as a host connects, also put a call to maildirsmtp into the host's connection script. Be sure to use the same lock file to avoid confusion if the cron job happens to run at the same time. If you add another host called purple, you only need to add another line to virtualdomains: purple.example.com:alias-dial-purple The remote hosts can use a similar setup to forward their mail to the main host, using a single smarthost entry in virtualdomains. See the discussion of serialmail in Chapter 11. |