Windows SMTP Server for Windows Sockets v1.61 Sunday, October 8, 1993 Technical Abstract This is a demonstration application of the Windows Sockets v1.1 API. This application only talks to SMTP "clients" according to the RFC822 specification, and to the sendmail variations. The application is cut into two almost separate parts. The NET.C portion that handles incoming connections and data, and the WSMTPSRV.C portion that actually does the SMTP "language" and the dialog box front- end. By keeping a separate SMTPCLIENT structure for each connection, the "state" of the connection can be monitored - and a separate FIFO buffer can be handled. By using a "net" FIFO side, and a "client" FIFO side, each separate part can be completely oblivious to each other. In fact, the WSMTPSRV side is completely oblivious to the network - if you realize it only uses netInit() and clientSendLine() and clientReceiveLine() to handle data. The server is a state machine. It can either be in a COMMAND state, or a WAIT FOR DOT state (for SMTP commands, or DATA messages). After each line is received from COMMAND state, it goes through a simple smtpParser() that handles each command. If the line was received during WAIT FOR DOT, it is added to the temporary mail file opened in the CMD_DATA case. If no more lines remain in the FIFO receive buffer, the smtpServer() routine returns. It will regain control again once more information is received in NET.C. The network portion is relatively simple as well. As a new connection comes in, smtpAddClient() adds this accept()'ed socket to the client array in the first open position. When the socket receives data, netReceiveData() is called to update the FIFO, and smtpServer() is called if something came in - this slighty breaks the distinction between the two portions. A better way to do it is probably to have the "language" portion register itself with the network procedure - this might suggest a DLL SMTPD in the future! Interested? For further information on Windows Sockets: ftp ftp.microdyne.com /pub/winsock/winsock-1.1/ ftp sunsite.microdyne.com /pub/micro/pc-stuff/ms-windows/winsock/winsock-1.1/ For further information on SMTP: {Basis of this program} RFC821 SIMPLE MAIL TRANSFER PROTOCOL, Jonathan B. Postel RFC822 Mail address formats {Currently working on the following} RFC1425 SMTP Service Extensions RFC1426 SMTP Service Extension for 8bit-MIME transport RFC1427 SMTP Service Extension for Message Size Declaration RFC1428 Transition of Internet Mail from Just-Send-8 to 8bit-SMTP/MIME {Used some of Sendmail's source as a guide } {NO CODE STOLEN, it wasn't very portable ;) } Sendmail source code from BSD4.3-Reno