JavaMail API - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

JavaMail Protocols

JavaMail Protocols

shape Description

JavaMail API is the concept related to email through the JavaMail. By using JavaMail API, sending, receiving, deleting, managing the email. JavaMail API is a platform, protocol independent framework for to send or receive mail. JavaMail API also provides core classes for to define objects and used that objects to maintain a mail system. Here are some JavaMail Protocols which support the JavaMail API, they are as follows.
  • JavaMail - SMTP
  • JavaMail - IMAP
  • JavaMail - POP3

shape Conceptual figure

Let us see the implementation of JavaMail Protocols in JavaMail API.

JavaMail - SMTP

shape Description

SMTP: It is an acronym for the “Simple Mail Transfer Protocol”, which issues a instrument to deliver the electronic mail(Email). An authentication is required in case of sending and receiving the emails through SMTP server which was provided by host server. An SMTP server also uses the Postcast server, ApacheJames server. To get SMTP server: The SMTP server is responsible for sending the emails, SMTP server provided by different servers like
  • Host provider provides SMTP server
  • ApacheJames server provides SMTP server
  • Yahoo, Gmail companies provides the SMTP server
  • Free SMTP server provided by jangoSMTP
These are the providers to use any one SMTP sever in our application. com.sun.mail.smtp provides SMTP protocol for to access SMTP server.

shape Table

Class Description
SMTPMessage It represents the MineMessage class which provides alll the parameters for sending a message.
SMTPSSLTransport By using SMTP SMTPSSLTransport implements the abstract transport class over SSL for transport and submission of message.
SMTPTransport By using SMTP SMTPSSLTransport implements the abstract transport class for transport and submission of message.

shape Table

The exceptions occurs in case of SMTP server
Exception Description
SMTPAddressFailedException when message sent failed then this exception occurs.
SMTPAddressSucceededException when mail.smtp.reportsuccess property shows true, then SMTPAddressSucceededException is chained off SendFailed Exception.
SMTPSenderFailedException when message sent failed then this exception occurs.
SMTPSendFailedException when message sent failed then this exception occurs.and includes senders address

shape Table

In the table listed below shows the properties of SMTP protocol that are set in session object in JavaMail API.
Type Description
mail.smtp.user It represents the SMTP username which is default.
mail.smtp.port It represents the port number of SMTP to connect too.
mail.smtp.timeout It represents the IO socket time out value.
mail.smtp.socketFactory The function of this class is to create SMTP sockects which implements javax.net.SocketFactory interface.
mail.smtp.socks.port It represents the socket port number of socks5 proxy server only if proxy server port number 1080 is not used.
mail.smtp.localaddress The local address represents the host name when creating SMTP socket and it is not mandatory to set by default socket class picks the address.
mail.smtp.auth.ntlm.flags NTML protocol represented flags.
mail.smtp.mailextension Which makes the extension string for to append to mail command.
mail.smtp.host Represents the SMTP server to connect.
Here in this package usage of class directly in application is not possible instead of that uses API defined by the javax.mail package

JavaMail - IMAP

shape Description

IMAP: It is an acronym for the “Internet Message Access Protocol”. It is an advanced one to receive the messages. For each user IMAP supports the multiple mail box and by multiple users the mail box shared. IMAP is defined in RFC 2060. It's have the feature to support both in offline and online operational modes. com.sun.mail.imap provides IMAP protocol for to access IMAP server. The IMAP protocol supplies access to IMAP message store and there are some IMAP extensions for supporting that have to query the server. The IMAP extensions are
  • UIDPLUS Support(RFC 4315)
  • MOVE Support(RFC 6851)
  • SASL Support(RFC 4422)
The IMAP store maintains a connection pool having IMAP objects for communicating with server.

shape Table

Class Description
ACL It represents the access control list for entry for specific identifiers and it is a class.
IMAPFolder It is a class and used to represent the IMAPFolder.
IMAPFolder.ProtocolCommand It represents user-defined IMAP protocol command.
IMAPMessage It represents a class and specifies ReadbleMine object.
IMAPStore It represents a class and provides access to message store.
IMAPSSLStore It represents a class and provides access to message store over SSL.
Rights It represents rights for authentication identifier.
sortTerm It is related to sort which was defined by RFC 5256.
IMAPFolder.FetchProfileItem It represents a class for fetching headers.

shape Table

The exceptions occurs in case of IMAP server
Exception Description
ReferralException It represents, in response code the failure of IMAP Referral indicates the AuthenticationFailedException  .

shape Table

In the table listed below shows the properties of IMAP protocol that are set in session object in JavaMail API.
Type Description
mail.imap.user It represents the IMAP username which is default.
mail.imap.port It represents the port number of IMAP to connect too.
mail.imap.timeout It represents the IO socket time out value.
mail.imap.socketFactory The function of this class is to create IMAP sockects which implements javax.net.SocketFactory interface.
mail.imap.socks.port It represents the socket port number of socks5 proxy server only if proxy server port number 1080 is not used.
mail.imap.localaddress The local address represents the host name when creating IMAP socket and it is not mandatory to set by default socket class picks the address.
mail.imap.auth.ntlm.flags NTML protocol represented flags.
mail.imap.mailextension Which makes the extension string for to append to mail command.
mail.imap.host Represents the IMAP server to connect.
Here in this package usage of class directly in application is not possible instead of that uses API defined by the javax.mail package and also creating instance of IMAPStore, IMAPFolder is not possible directly with application for that have session method getStore.

JavaMail - POP3

shape Description

POP: It is an acronym for the “Post Office Protocol”, Which supports to receive the email. For each user POP supports the single mail box. POP is defined by RFC 1939. com.sun.mail.pop3 provides POP3 protocol for to access POP3 server. The server listens as port 110.

shape Table

Name Description
POP3Folder The folder should be INBOX.
POP3Message It represents POP3 message.
POP3SSLStore It represents POP3 message over SSL.
POP3Store It represents POP3 message store.

shape Table

In the table listed below shows the properties of POP3 protocol that are set in session object in JavaMail API.
Type Description
mail.pop3.user It represents the POP3 username which is default.
mail.pop3.port It represents the port number of POP3 to connect too.
mail.pop3.timeout It represents the IO socket time out value.
mail.pop3.socketFactory The function of this class is to create POP3 sockects which implements javax.net.SocketFactory interface.
mail.pop3.socks.port It represents the socket port number of socks5 proxy server only if proxy server port number 1080 is not used.
mail.pop3.localaddress The local address represents the host name when creating POP3 socket and it is not mandatory to set by default socket class picks the address.
mail.pop3.ssl.enable Set as true for default use of ssl but defaults to false.
mail.pop3.ssl.checkserveridentity By default it is false, when set to true then check the identity of server represented by RFC 2595.
mail.pop3.host Represents the POP3 server to connect.
Here in this package usage of class directly in application is not possible instead of that uses API defined by the javax.mail package nd also creating instance of POP3Store, POP3Folder is not possible directly with application for that have session method getStore.

Summary

shape Key Points

  • JavaMail Protocols - SMTP which issues a instrument to deliver the electronic mail(Email).
  • JavaMail Protocols - Host provider provides SMTP server.
  • JavaMail Protocols - com.sun.mail.smtp provides SMTP protocol for to access SMTP server.
  • IMAP is an advanced one to receive the messages.
  • com.sun.mail.imap provides IMAP protocol for to access IMAP server.
  • It's have the feature to support both in offline and online operational modes.
  • POP server which supports to receive the email.
  • com.sun.mail.pop3 provides POP3 protocol for to access POP3 server.
  • Properties of SMTP, IMAP, POP3 protocols are discussed.