Windows SMTP Server for Windows Sockets v1.61 Sunday, October 8, 1993 wsmtpd16.zip Announcing a WinSock 1.1 compliant SMTP daemon for Windows. This is a public domain program, and I am releasing it somewhat as Lee Murach has with his TXTSRV program. All source code is included, I can't accept any money for it, and I don't want the headache of supporting any program. What I do want is for programmers in the public domain to include this source code in thier mail programs, and possibly as a skeleton in other daemon programs. This server was written with reusability and speed in mind. You should be able to find this program on the following FTP sites: FTP.MICRODYNE.COM /pub/winsock/apps/wsmtpd16.zip SUNSITE.UNC.EDU /pub/micro/pc-stuff/ms-windows/winsock/apps/wsmtpd16.zip (this is a mirror of Microdyne, give it time to catch up) FTP.CICA.INDIANA.EDU /pub/pc/win3/programr/wsmtpd16.zip (or /pub/pc/win3/uploads/wsmtpd16.zip for the near future) ************** ** Versions ** ************** wsmtpd10.zip v1.00a June 22, 1993 - Origional release wsmtpd11.zip v1.10a June 22, 1993 - Fixes a WSAENOTCONN problem with Lanera's TCPOPEN WinSock DLL - "Might" be causing only one connection to be accepted at a time, but I think this is Lanera's problem. - Another version might be out to fix any glitches. wsmtpd12.zip v1.20a June 22, 1993 - What did I tell ya? This SHOULD have been v1.0! Owell, It's stable now on the Lanera stack. Haven't tried Chameleon. - Received data is flushed correctly now. The other versions didn't like mass dumps, this one doesn't care. - "Title bar" in the debwsmtpd.exe binary tells you the current progress with all of the clients as things go - but only if you have "debug" on. - "Title bar" resets to "WSMTPD" when no mail remains (the file is deleted). - This should be the last release for the near future. ;) Actually, this version is stable enough, as long as you don't quit it and retry running it. Somehow Im not freeing the listening socket. wsmtpd12.zip v1.20b June 23, 1993 - Fixed HELO, fixed line length problem wsmtpd12.zip v1.20c June 24, 1993 - Fixed stack problem caused by v1.20b wsmtpd13.zip v1.30a June 24, 1993 - 8BITMIME capabilities. ESMTP compliant. - Fixed RECV and MAIL replies. - Fixed the resource strings and smtpSendMessage() - Added a 'local ESMTP extension' of XWIN3 to the server. - Fixed NUMEROUS misspellings. Cleaned things up. - As long as nothing is connected, closing the app and restarting isn't a bad thing anymore - Don't know about Chameleon though. wsmtpd14.zip v1.40a June 28, 1993 - Fixed code to use Linked list for client structures. There is no longer a limit on the incoming number of connections. - Fixed receiver buffer overflow error on long messages. I had to find out what the TCP/IP kernel was buffering to, and then duplicated the same amount of memory. This is only for the receive buffer though. - Took out "phase" garbage. Debugging is past that point - Changes alot of the code for the new LPSMTPCLIENT type to replace the old int iIndex. This and alot of replacements of LPSTR for PSTR. - Fixed a problem with buffer overflows. Note #1: Chameleon telnet WILL freeze if you try to send a large PASTE from the clipboard (It seems to overflow its buffers). wsmtpd14.zip v1.40b June 28, 1993 - GPF during closed connections aborting DATA transfer problem fixed. - 500/501 twin messages during bad RCPT/MAIL commands fixed. - Now prints a "%s Disconnected!" message when smtpDestroyClient() is called. - Still gets stuck in a infinite loop somewhere. This WILL be fixed if I can consistently duplicate it. - If a client send more than the edit control can handle between smtpSendMessage() calls, the connection seems to hang. Just turn off debug mode if you aren't debugging!!! wsmtpd15.zip v1.50a June 28, 1993 - The listbox bug is fixed. Everything should be completely stable now. I have tested messages of 120k in size - in rfc822 mode - and it works perfectly. - This might be the last major release of WinSMTPSrv wsmtpd15.zip v1.51a July 2, 1993 - Fixed problem with server "eating" empty lines - Fixed a bug with MULT returning 2 messages - Added .BAT files for PCTCP "mail" users like me. Do NOT try running this program on PCTCP's v1.06 WinSock DLL - it doesn't work right. Instead, try getting Lanera and PCTCP to work together, and use Lanera's DLL while in Windows. wsmtpd16.zip v1.61 October 8, 1993 - Fixed the funky icon problems (thanks to May '93 DrDobbs) - Took out unneccisary calls to setsockopt() and WSAAsyncSelect() where they weren't needed. - Included a call to getservbyname() for SERVICE database lookups of the "smtp" port... if the call fails, I hard set it to port 25. - Updated this README file to be kinder to certain Vendors who's stacks have improved dramatically.... - I have some worries about how I implemented my netSendData() procedure, as it should sit in a loop trying to send until WSAEWOULDBLOCK... but it does currently work just fine without. ************** ** Features ** ************** 1. Almost completely NON-BLOCKING, and FAST (only the blocking gethostbyaddr() call is used). 2. No 'theoretical' limit on the number of incoming connections. Most TCP/IP stacks limit the maximum number of sockets to something like 64. All of the connection structures/buffers are locked into memory, using handles and locking at the beginning of each slice would be too much overhead. 3. Easy reusability for future daemons. 4. All message strings are Resources; all commands are looked up in a structure array for easy switch()/case parsing. 5. FIFO buffers for input/output. Allows for, among other things, manual intervention with the server (including Backspace and Delete for non- linemode telnets: try "telnet localhost 25"). 6. Fully implemented SMTP HELP. So many commands... I even grabbed a few that the RFCs didn't talk about; I could only implement the majority, however. 7. Extended SMTP as defined in RFC1425/1426/1427/1428. The SIZE extension is not yet implemented. 8BITMIME is! ********************************* ** Features lost to simplicity ** ********************************* 1. Exotic front end dropped in favor of a quick and spiffy dialog box. 2. All mail is put in one file. This was origionally intended so that I might read it with FTP's mail program. Too bad their DLL doesn't work right yet. 3. Mail is NOT forwarded, and recipients are NOT checked. Everything that is accepted is written to the mail file. 4. The listbox is NOT a virtual one. After 1000 (MAXITEMS), the listbox is reset so that the program doesn't crash. ******************************* ** Possible current problems ** ******************************* 1. WSAAsyncGetHostByAddr() Never did quite work right, so I went with the blocking gethostbyaddr() - no pauses noticed (except sometimes over SLIP). 2. Buffer size of 2048 means that the maximum line that can be used is limited to this. If this is overwritten, the server just seems to suddenly shut up. The Receive buffer makes itself the same size as the SO_RCVBUF value returned from getsockopt() - older versions did not! Future versions, based on RFC1427, might dynamically allocate the FIFO buffer as needed. ESMTP extensions are in place, I just have to decode the SIZE extension. It looks like I don't have to worry... but you never know. 3. The RFC info is a little confusing in places, so if I have anything wrong, please tell me. 4. Lines over 2048 characters in length do BAD things. This limit is only with the 7bit RFC-822 code, the ESMTP 8BITMIME bypasses such limits in the message (block, not line, oriented). 5. The list box should probably be made into a virtual one. But this aspect of a SMTP server is beyond the scope of the project. A log file might be added in the future if the POP3 and multiuser capabilities are in place. 6. Stupid Icon flag keeps updating every 30 seconds when there is mail. When no mail is present, the timer is turned off until more is received. 7. If two programs try to access the mailbox at the same time, all hell breaks loose (nice little dialogs pop up). 8. The SMTP port (25), is not derived by getportbyname() *********** ** Notes ** *********** There are 2 binaries. The DEBWSMTP.EXE version has all of the debugging symbols linked in, and the "USE_TITLE" definition set. The WSMTPSRV.EXE version is the clean "release" binary, with the "USE_TITLE" commented out. If you minimize WSMTPD, no error messages will go to your screen, they will all go to the dialog's listbox. If you delete your mailbox after reading it, the flag icon will go back down. The listbox will occasionally reset - so don't depend on reading your mail through it. Every 1000 (MAXITEMS) lines it clears the hole thing. **************** ** Installing ** **************** You MUST have Windows v3.1 and a WinSock.DLL installed with your TCP/IP package. Copy CTL3D.DLL to your C:\WINDOWS\SYSTEM\ directory. Copy WSMTPSRV.EXE to your favorite network utils directory. Open up filemanager, and click and hold on WSMTPSRV.EXE and drop it into your favorite network group in Progman. Double click on the new icon. Click on the MAIL> button. Choose a file for your Mailbox. Minimize WSMTPD to avoid the nasty error messages. Get real work done and receive SMTP mail! My installation: Clarkson 3c503 driver pktmux 3 pktdrv's PC/TCP 2.2 Kernel Lanera's Kernel WinSock.DLL (demo version for testing compliance). Other neat WinSock software that goes well: WinTrumpet HGopher WinQVT/Net ******************************** ** The Agreement of all users ** ******************************** Ian Blenke cannot be held responsible for damages, expressed or implied,for the use of this software. No commercial use can be made of this product without the consent of the author. No profit of any kind can be made on the sale or distribution of this program. If you wish to distribute this program with other samples of WinSock programming, you must first contact the author so that he can keep accurate records of its usage. If after 3 months, you still cannot get the author's attention, this program can be distributed IN ITS CURRENT FORM with any other samples; you may not, however, gain any profit from its distribution. If I think you have distributed any of this program without adequate notification, I will require you have proof that you did try. If you write any programs based on this source code, you may not sell them for any profit without the written consent of the author. If you incorporate this source code into a public domain program, all the author requires is a notification that "part of the code was written by Ian Blenke" and some form of notification that his name was used in the public domain software distribution. This does not represent a contract on the part of the author. If any issues cannot clearly be resolved by reading this text, immediately contact the author. I do not wish any profit from this program and I don't need the responsibility. You may not make a profit on this software, the author hasn't. I don't like such agreements, but in today's world of lawyers and lawbreakers I have little other choice. ****************** ** Future Plans ** ****************** - SMTP client - A VisualBasic project is in the works - looks good. - Definite ESMTP compliance. - Multi-user capability. This is neccisary for the POP3 server as well. - POP3 server in the works - it's on paper. - POP3 client wanted. Haven't started on it yet. (But there are MANY) - MIME client for SMTP/POP3 wanted REAL bad. Someone is working on it. - A WinSock client VBX is already a reality. Currently in alpha testing, it includes 4 clients: WinRSH/WSMTPC/WFinger/VBTest. When the control is beyond it's alpha testing stages, I will release it to Microdyne with complete source. (If you are interested in participating in the alpha testing, let me know) (I learned a lesson with versions 1.0 to 1.3 of WSMTPSRV! ;) ******************* ** Compatibility ** ******************* Versions known to work with this version: - PCTCP v1.09beta2Y and newer. Bob Quinn from FTP Software Inc. (rcq@ftp.com) has been a great help in getting this example code to work with PCTCP's WinSock.DLL - PCTCP v1.09beta1 will only carry on 1 conversation, so you have to close and restart the window for each connection (this is a bug that has been fixed in 1.09beta2Y and newer) Versions not sure of: - Lanera might not work any more... But I no longer use it, so I can't confirm my concept. It seems that when you close the child accept()ed socket from a listen()ing one, the event mask set by WSAAsyncSelect() is forgotten. - Or so it seems. - Chameleon should work... I had a good experience with their WinSock in my first few versions. But I cannot confirm wether this will work on thier. - Distinct hasn't been tested at all. - SuperTCP hasn't been tested at all. - LWP hasn't been tested at all. ********************* ** About the Author * ********************* I am a student currently in search of an education. If anyone out there believes that this little project shows any hope, I would like to hear about it. It isn't too bad for a Community College student (that had to teach himself everything he knows). ;) Have fun! harris.iblenke@ic1d.harris.com // should work for a while iblenke@rhino.ess.harris.com // should work about as long (407)725-6073/3887 // Use sparingly Home/Data Remember, if you can't reach me after 3 months, and you don't see any newer versions, the package can be distributed IN ITS ENTIRETY as long as it does not make a profit for ANYONE.