SMPT
Johnny Papa and Peter DeBetta

      SMPT and POP3 combine to provide what most people know as their Internet mail service. POP3 provides the mailboxes and the incoming mail service while SMTP performs the outgoing mail service. Although SMTP accepts incoming mail, its primary function is to place the mail in a queue to be sent out to other destinations.
      The Microsoft® SMTP Server is more than just a means of sending mail. Like a POP3 server, it can receive and store incoming mail not only for itself, but for any number of users. Unlike a POP3 server, SMTP does not provide a secure means of managing mail and mailboxes, and all the incoming mail is placed in a single Drop directory.
      If you look at the Microsoft Management Console (MMC) in Figure A, you can see the SMTP service and its associated domain in the tree structure. While Domains is selected under the SMTP service, the domain name information can be seen on the right panel of MMC. This domain is the key to having the SMTP service receive incoming mail. On an Internet-based server, the domain name needs to have a DNS entry so that mail is redirected to this server. The mail in this example should be sent to server.domain.com (sysop@server.domain.com). Although the user name portion of the mailto address can vary, all the mail is placed in the Drop directory and is managed by the SMTP service.

Figure A
      Figure A

      When logging on using CDONTS, you supply a user name and mail address to filter a drop directory (making it feel a bit like using a mailbox). No security is required to get the mail, as shown in the following Visual Basic® 6.0 code snippet:
 Set objSession = New CDONTS.Session
 objSession.LogonSMTP "sysop", "sysop@server.domain.com"
      You can see that no password is required to gain access to the mail for the user sysop. This code, however, must run on the same server that hosts the SMTP service. Thus, only local ASP scripting and local COM objects can access the incoming mail.
      One last note: you cannot rename a domain once it has been created for the SMTP service. Since the domain name is the key to receiving mail, you must have a domain entry whose name is qualified to receive mail. If your domain name needs to be changed, you can follow these simple directions:
  • Add another domain (with the correct name) by right-clicking on Domains in the MMC tree under your SMTP site
  • Right-click on the new domain (in the right pane of MMC) and choose Properties
  • Change the Local information from Alias to Default and click OK
  • Click Yes when prompted with a confirmation dialog
  • Right-click the old domain and choose Remove
      You now have a default SMTP domain with the correct name to which you can send mail for your SMTP service. SMTP also provides for incoming and outgoing messaging through its use of storing messages in a folder structure within the Inetpub/MailRoot folder. The folders and their functions are listed here:
Drop This folder stores all incoming messages sent to the SMTP server
Pickup All messages placed within this folder are sent to their recipients by the SMTP service
Queue If a message cannot be sent to its recipient for any reason and the maximum number of retries has not been reached, the message is placed in this folder
BadMail Once the maximum number of retries has been reached, SMTP places the failed message into this folder
      Using this folder structure, SMTP can manage incoming and outgoing messages on Windows NT Server. You have access to these messages through the CDONTS object library. You can use the NewMail object for simple outgoing messages or attachments. If you require more advanced features or more flexibility than the NewMail object provides, you can take full advantage of the remaining objects in CDONTS that begin with the Session object. Through the Session object you can log in to SMTP and retrieve messages sent to the user as whom you logged in. Whatever object you use within CDONTS to utilize SMTP as a mail server, one thing is for sure: coding to manage messaging is no longer the chore it used to be.


From the February 1999 issue of Microsoft Internet Developer.