Dovresti studiare i comandi che possono essere dati ad un server SMTP ...

Potresti cominciare dall' RFC821 ...

http://www.ietf.org/rfc/rfc0821.txt