SMTP : Java Glossary
home S words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish by Roedy Green ©1996-2008 Canadian Mind Products
Go to : punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
SMTP
Simple Mail Transfer Protocol. The protocol most commonly used for sending mail to a server. In JDK 1.2+ you would use the JavaMail API. In JDK 1.1 there is an undocumented package for sending mail: sun.net.smtp. You use it like this:
SmtpClient c = new SmtpClient( server );
c.from( sender );
c.to( recipient );
PrintStream p = c .startMessage();
p.println( "" );
p.println( "Subject: Test of SMTP Server" );
p.println( "" );
p.println( "Hi" );
c.closeServer();
SMTP is so simple you could roll your own code to send mail with it using a URLConnection. Here is David Flanagan’s source code to do it that way. Here is the Java Boutique code for SMTP.

SMTP is a kludgy anachronism. It lives on simply because everyone uses it. One of its major failings is a lack of authentication protocol. It has no official logon mechanism to prevent spammers from using your mail server to dispense SPAM.

Mail servers use various ad hoc schemes to protect themselves from unauthorised use:

  1. Looking at the FROM: and REPLY-TO: in the mail header. This is so easy to defeat, newbies do it by mistake.
  2. A manually maintained list of valid IPs permitted to use the server. Nasty people can still spoof IPs.
  3. You login with POP3. Your IP goes into a temporary list of valid SMTP users. This means you must always attempt to pick up your mail immediately before sending any new mail.
  4. Kerberos login.
  5. A login command at the start of the SMTP session.
  6. More advanced mail protocols.

RFC 821 describes the SMTP send mail protocol. You would use this to implement SendMail at the socket level with HELO commands and numbered responses.

If you talk to a mailserver, you can send mail to anyone in that domain without identifying yourself, however, if you want the mailserver to relay mail for you outside its domain, you need some way of identifying yourself. Mailservers drop off relayed mail using that same SMTP protocol.


CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.18] The information on this page is for non-military use only.
You are visitor number 19,970. Military use includes use by defence contractors.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/smtp.html J:\mindprod\jgloss\smtp.html