Multidomain post system using IPS


to russian page

I had such tasks:

  1. SMTP server (only imcoming) serving many domains and users.
  2. POP3 server for a lot of users and domains, with identical names in different domains (e.g. postmaster@domain1.com and postmaster@domain2.com).
  3. All this should use a single IP address.
  4. Special "domain accounts" should exist: if specified user is not found, but such domain exists, all mail should fall to this special account. And it is necessary only for some domains.
  5. Addition of domains and users should not require server restart and should be automated simply.
  6. The solution should have text configs (see 4) and do not require PM (I administrate this server via ssh only)
  7. Some domains are aliases (for example alias.com and domain1.com).
I has not found ready OS/2 solution for this task. The idea to use sendmail, local sorter and separate pop3d did not involve me. Then I found IPS server (www.inetpowerserver.com). I was interested only in its pop3/smtp components. The internal support of domains was not suitable for me because of impossibility to realize items 2, 4, and 5. But IPS has Rexx Hooks Support -- that has allowed me to create a system matching all my requirements :) Below I shall try to describe how it works and how to use it on your server.

I advise you to use latest IPS version for this solution. You can read in the documentation how to configure it, and I shall speak only about adjustments specific to our task. The section [SMTP-1] in my config file contains such settings:

[SMTP-1]
Address=217.66.96.131
# my ip address
Protocol=smtpd
ClientAddress=*
Host=smtp
ForwardAddress=
ForwardToServer=
QueueDirectory=.\queue\mail
LocalDomain=localhost
# You need to specify ONLY localhost here.
LocalDomains=@localhost @[127.0.0.1]
hookOnCommand=.\scripts\smtp\rxOnCommand.rexx
# our rexx script.
From mentioned above follows that IPS thinks that it serves ONLY 1 domain, and IPS starts a script rxOnCommand.rexx on every command. The second part of my article describes the work of the given script.

What this script does.

  1. Intercepts line RCPT TO: and also parses e-mail to domain and user name. Checks established aliases and replaces them with the main domain (see a line after /* alias1 */).
  2. Reads a file specified in a variable domain_file (a text file containing list of local domains, line=domain) and checks out if our domain exist. If domain is not present, it returns a line without changes (then IPS will answer that forward not allowed).
  3. If it is our domain we search for the user like user%domain (e.g. samm%domain1.com). If such user is found, we return to ips string like "RCPT TO: <user%domain@localhost>" (in our example - RCPT TO: <samm%domain1.com@localhost>). If user is not found, script will return string like "RCPT TO: <domain@localhost>" (in our example - RCPT TO: <domain1.com@localhost>).
That's all :) Now I shall try to describe how to use it.
  1. Install IPS and adjust section [SMTP-1] according to my recommendations.
  2. Copy a script in IPS\scripts\smtp\rxOnCommand.rexx.
  3. Edit variable domain_file in rxOnCommand.rexx to specify a file where you plan to place the list of domains. Create this file and place to it all of your domains and aliases (string=domain).
  4. write all your aliases (if they exist) after line /* alias */ in rxOnCommand.rexx in the followinf way: if domain ='alias.com' then domain ='primary.com' /* alias */
The mail server is ready to use. Now we shall create users.
  1. If we want to create the user who will receive only messages addressed to him (e.g. samm@domain1.com) create the user with a name like user%domain (in our case samm%domain1.com). Now all messages addressed to him will be placed to his mailbox. His pop3 login will look like user%domain (in our example -- samm%domain1.com).
  2. If we want to create the user receiving a mail on all domain (in a case if user-addressee is not found) it is necessary to create a user whose name is equal to domain name (for example, domain1.com). His pop3 login will be domain (in our case domain1.com). That's all.
It would be nice to add that now my system serves 16 domains, 3 aliases and more than 60 users :)
Alex Samorukov (Samm)