From: Francis Cianfrocca Date: 2006-11-01T07:13:38+09:00 Subject: Re: simple smtp server ------=_Part_8762_27733247.1162332814047 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/30/06, mmalaidini@gmail.com wrote: > > Hello folks, > > I'd like to understand if anybody has ever written a very simple smtp > server (supporting SSL authentication). I'd like to write an stmp proxy > for my own personal usage and I'm trying to understand where to start. > > TIA > MM > > > I've written SMTP servers several times in Ruby and in C++. You're not too specific about the point of the exercise. Are you looking to learn about network programming and SMTP in particular? Or are you looking for a quick solution to a narrowly-defined problem? I would start by reading RFC-821 and RFC-822. SMTP is a very old protocol, designed long before the dominance of IP and of TCP, and written to be usable interactively by humans at a command prompt as well as by automatic agents. It's very simple to understand but deceptively difficult to implement, so don't underrate it. It's not like more modern protocols that may appear to have more functionality but are actually less complex grammatically and easier to implement. Keep the parsing of message headers (RFC-822) separate in your mind from the protocol state machine (RFC-821). The creators of SMTP (one of whom was the late, great Jon Postel) were wise to split it into two documents. Headers can be dealt with easily enough in Ruby with regular expressions but the protocol stream is best dealt with as a FSM. Look at the EventMachine library for a framework that will relieve you of the need to deal with all of the network and server-architecture headaches. You still have to deal with SMTP, although at some future point EventMachine should have built-in support for SMTP (as does Twisted, EM's older brother in the Python world). Good luck. ------=_Part_8762_27733247.1162332814047--