Implementing Microsoft Exchange™ Mail on Demand

Introduction

Microsoft Exchange is an e-mail server that can be used to handle local (Intranet) email. It can also be configured to send and receive outgoing (Internet) mail on demand (dial on demand). For more information on the Exchange Server, please see:

http://www.microsoft.com/products/prodref/49_newf.htm

Not only can Microsoft Exchange be used as a local mail server to handle your intranet mail, but it can also be configured to send and receive mail to and from the Internet. Typically, a dedicated Internet connection, including the purchase of a high speed line (T1), a router, a CSU- DSU, a firewall, DNS Servers, etc, would be required in order for your Local Area Network (LAN) to send and receive Internet mail. The capital required to make such a commitment, in most cases, is far too high and prohibits small to medium sized businesses from integrating the Internet into their LAN or Intranet.

However, with the Microsoft Exchange server, you can have the server dial- up to your local ISP on demand, then connect to the mail service on your Virtual Server and download any stored mail. This allows you the ability to have continuous e- mail support on your local intranet where traffic is heavier, in addition to being able to send and receive e- mail to and from the Internet on a more periodic basis. You should be aware that Digital Daze does not currently have a solution for MS Exchange for Virtual Hosts. We may have this solution in the future (technically the Virtual Server will handle this just fine), but until then, if you desire to use this solution for Virtual Hosts you will be responsible for the sendmail configuration changes.

Because your Virtual Server is always connected to the Internet, it is always available for incoming mail messages and can store (or queue) these messages for you until you are ready to retreive them. The ability of the Microsoft Exchange server to perform dial-on-demand e-mail retrieval allows you to take advantage of the lower prices of a dial-up connection, providing a more affordable Internet mail solution for your company. The information provided here should be easily adaptable for any other Mail Server, such as Novell’s Workgroup Server.

The diagram below illustrates the theory behind the process.

exchange.gif (18462 bytes)

You and your fellow employees are located on your LAN or Intranet at Your Office.

You use a dial-up connection through Your ISP to surf the web, read news, download files, and remotely administrate Your Virtual Server. You may have previously had both an internal LAN mailbox and a POP or IMAP mailbox on your Virtual Server.

Using the Microsoft Exchange server (or equivalent software) you can now queue your Internet mail on your Virtual Server and instruct Microsoft Exchange to periodically connect to the Internet, download the mail from your Virtual Server, and then distribute it to your local area network mailboxes.

Exchange client side configuration

On the client side, you will need to configure the Exchange Server to dial-up to the local ISP on demand. How to do this should be documented in your Exchange Server manuals. A great additional resource is provided by Simpler Webb: http://www.swinc.com/resource/exch_smtp.htm.

In essence you need to:

  1. Configure your RAS/DUN.
    1. You will need an entry in the phonebook that makes an automatic connection to your local ISP at the intervals you specify.
    2. You need a TCPIP hostname and domain configured in Control Panel/Networks/TCPIP
  2. Configure the Exchange SMTP service. For Exchange 5.0 this will be the Internet Mail Service. This should be pointed to the SMTP server for your Virtual Server (smtp.yourdomainname.com)
  3. If necessary, configure the SMTP Addresses for your users. You can globally configure this using the Site Addressing configuration page, or you can use Directory Import to configure individual addresses. This would only be necessary in the event you had multiple users in your “Intranet” that had a different Virtual Server.
  4. Now, you need to configure the server to tell the mail server to dequeue mail. You will need to configure your Exchange Server to run the “etrn” command. This command tells the Virtual Server to attempt to resend your queued mail. A script written by Simpler Web Inc. will help set up your Exchange server to do this:

    http://www.swinc.com/files/dequeue.exe

    In essence, you’re connecting to your smtp port and telling the mail server you want to dequeue your mail. For those people not using MS Exchange, you could write your own script. Here is an example UNIX shell script that would do the same (substitute your domain name for my-domain.com).

        #!/bin/sh 
        # http://www.swinc.com/resource/exch_smtp.htm 
        # Send ETRN command to sendmail 8.8.x 
        # written by Andy Rabagliati <andyr@wizzy.com> 
        # 
        telnet mail.my-domain.com smtp <<SMTP_EOF 
        ETRN my-domain.com 
        QUIT 
        SMTP_ EOF 
        # 
        # End of Shell script 
        # 

    Or alternately

        #!/bin/sh 
        OURSITE=exchange.isp.com 
        MAILSERVER=mail.sfpsi.com 
        TELNET=/usr/bin/telnet 
        PORT=25 
        
        echo "etrn $OURSITE" |$TELNET $MAILSERVER $PORT 
        exit 0

ISP Configuration

You must have a dedicated IP address for the MS Exchange Dial-up solution to work. There is no other alternative to this. This will require either that you:

  1. Purchase a dedicated modem at your ISP’s modem bank that only you connect to and that is assigned your dedicated IP address
    OR
  2. Your ISP has the ability to detect when you dial in and can assign that dial-in your dedicated IP number.

The second thing your ISP must do for you is map a domain name to that dedicated IP address. For example, if your local Internet Service Provider has a domain name “myisp.com” and they were going to give you an IP address of 222.222.222.222, you want them to map 222.222.222.222 to a unique instance of my-isp.com. As an example:

exchange.myisp.com mapped to 222.222.222.222 Here is an example dns entry for this:

    @                IN SOA ns1.my-isp.com. hostmaster.my-isp.com. ( 
                            1997072802 ; Serial number 
                            86400      ; Refresh 
                            7200       ; Retry 
                            2592000    ; Expire 
                            172800 )   ; Minimum TTL 

                     NS     NS1.MY-ISP.COM. 
                     NS     NS2.MY-ISP.COM. 

                     A      222.222.222.1 
                     MX 10  my-isp.com 

           exchange  A      222.222.222.222 

Another alternative would be to use your Virtual Server domain name in the zone file above instead of the name “exchange”. For example if I had a Virtual Server and my domain name was for the Virtual Server was internetservers.com I might have my ISP set up their dns zone file to point to

    internetservers  A      222.222.222.222 

Now, all mail sent to internetservers.my-isp.com would resolve to the dedicated IP address 222.222.222.222

This is important, you must have a dedicated IP address (one that is uniquely assigned to your Exchange Server), and you must have a domain name pointing to that IP address for the MS Exchange solution to work.

Virtual Server Configuration

You need to do two things:

  1. Mail service@digitaldaze.com and have them edit your zone file for your Virtual Server domain.

    You will want them to add an additional mx record into the zone file. If you had your ISP configure their DNS server as outlined above, and the name of your Virtual Server was “internetservers.com”, the entry would be as follows:

        MX 10 internetservers.my-isp.com 
        MX 20 internetservers.com

    MX stands for “Mail eXchanger”. The Internet knows how to send mail to your domain by looking at these MX records. In this zone file, we are saying that the Exchange Server (internetservers.my-isp.com) has the first priority for mail delivery (MX 10). Your Virtual Server (internetservers.com) has second priority (MX 20). If mail can’t be delivered to the first priority mail server it is sent to the second priority mail server. Since your first priority mail server is generally not going to be connected to the Internet at the time someone sends you an e-mail, the Virtual Server will receive e-mail for your domain name. Then, when you log in with your Exchange Server, your Virtual Server will send your Exchange Server your mail.

  2. After DNS has been properly configured, set up your virtual server to perform mail dequeuing as described in the section below.

Configure the Virtual Server for Exchange Mail Dequeuing

  1. Setup the Virtual Server to queue up mail until the ETRN command is received from the Exchange client.

    1. Add the following line to the Options section of the etc/sendmail.cf file on the Virtual Server:

        Oddeferred                  # defer mail on the server
        

    2. Comment out the following two lines in Ruleset 0:

        R$+<@$=w>               $@$>90$1                Remove local addresses
        R<@$=w>$-$+             $@$>90$3                Remove local routes/UUCP
        

      These two lines let the server know what domains are local the the Virtual Server. For mail dequeueing, nothing should resolve locally.

    3. Add the following line to the Virtual Server cron:

        00 0-23/4 * * * /usr/local/bin/virtual sendmail -q
        

      This will flush out the Virtual Server mail queue every four hours. You may need to modify this according to how long the Exchange client may be off line. Everytime an attempt is made to flush the queue, a hop is added to the headers for each messages queued up. This means that if you set the cron to flush the queue every 15 minutes then an addidtional hop would be added every 15 minutes. This would mean that after 6 hours in the mail queue, a message would have 24 hops (where the maximum is 26). Therefore, any mail older than 6 1/2 hours would be bounced with "too many hops".

There are a couple of things to note here. First, all mail (incomming and outgoing) will be held in the queue until it is flushed out, either by an ETRN command or the flush command in the cron. This means that if the cron is set to flush every 4 hours, an outgoing mail could wait 4 hours before it is sent from the Virtual Server. Also, mail dequeuing will affect all domains on the Virtual Server so only one domain should be on the Virtual Server unless ALL domains on the server are using the mail dequeuing feature.