• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Programming an SMTP Server

 
Ranch Hand
Posts: 116
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I wanna develope a simple relay smpt-server in java.
But i dont know how to implementate the protocol.

Can you recommend a book to me?


Thank you in advance.


Greetz
 
Saloon Keeper
Posts: 7585
176
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Might a combination of reading the relevant RFCs and looking at the source code of an existing server (like Apache James) do the trick?
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are books that deal with mail servers, like O'Reilly's SendMail "bat" book, but they are geared towards configuring and using mail, not coding your own.

The definitive information on how SMTP works was Postel's RFC821, superceded by RFC2821, which was superceded by RFC5321, updated by RFC7504.

The Request For Comments (RFC) documents are generally pretty clear, since they are the authoritative definions of the services and protocols that they define. You have to like monospaced type, though.

SMTP is actually pretty simple. You can even operate it from a telnet text session, since like most of the original Internet protocols, it runs off text commands. That's in part because in the early days of the Internet, the different computers in the Internet might be using ASCII or EBCDIC, but text is text and easily translated from one codeset to another, but binary can be a real mess, since word sizes and byte orders vary all over the place.

So in essence, you log into the SMTP server (usually via TCP port 25) with a text command, issue another command that says you're sending an email, send the email (if there are binary attachements, they have to be MIME-encoded into text), end the email with another text marker, repeat as desired until you're done. SMTP only sends mail - to receive mail, you need a POP or IMAP server, which are different protocols, different RFC's, and often different programs as well.

The original SMTP was all straight text. Later versions have added features, most notably encryption, but you can start with the basics and build your way up from there.
 
Ralf Coby
Ranch Hand
Posts: 116
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks fpr reply,

so I'm going to read the RFCs, inspect some codes and buy a book from Stevens.


Thanks
 
Marshal
Posts: 4501
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a good document written by Vladimir Riabov of Rivier University which provides a very good explanation of SMTP which can be download from ResearchGate here for free - no account required.  The document was uploaded by the author, so I assume that there are no permission required to download it.  It is a scan of a printed document so the visual quality is not great, but the content is very good.
 
Bartender
Posts: 1868
81
Android IntelliJ IDE MySQL Database Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When creating your SMTP server please ensure that you provide a way to secure/configure it so that it does not become an open relay.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic