JavaMail Interview Preparation Guide
Download PDF

JavaMail frequently Asked Questions in various JavaMail job Interviews by interviewer. The set of JavaMail interview questions here ensures that you offer a perfect answer to the interview questions posed to you. Get preparation of JavaMail job interview

7 JavaMail Questions and Answers:

1 :: Explain JavaMail?

Java Mail is an API that is used to receive and send emails between applications. To send the emails, the protocols, SMPT, POP AND IMAP are used. The messages sending and receiving is done by creating a framework using set of abstract classes in the API. The framework allows the application to create customized cross-platform mail application by having basic knowledge of e-mail. There are methods and classes that are used to access mail folders, message downloading and sending messages along with attachments feature.

Potential advantages include - Java mail is used to create personal mail filter, simple mailing lists and personal mail applications. Java mail also includes the capabilities to add the emailing process to an enterprise application or even to create a full-fledged e-mail client. Many companies in the industry have written new e-mail clients using Java Mail.

2 :: What is POP?

The Post Office Protocol is an application-level protocol within an intranet which are used by the local e-mail clients to send and retrieve e-mails from a remote server those are connected using TCP/IP. POP is one of the most prevalent protocol fro the usage of e-mail. The POP and its procedures support the end-users with dial-up network connections.

POP allows the users to retrieve e-mail when connected and later allows viewing and altering the retrieved messages. This is done with a promising feature – without staying connected. The process of using emails over POP is to connect, retrieve the messages, and store them on the user’s PC as a new message. Later these messages can be ‘deleted from the server’ and disconnecting the server – makes POP a distinguished protocol.

3 :: Can you explain SMTP?

Simple Mail Transfer Protocol, for sending email between ‘servers’. Most of the emailing systems implement the messages over internet use SMTP. The message sent from one server to another server, and then the message can be retrieved by an email client. The client uses either POP or IMAP. In addition to this process, SMTP is also generally used for message sending and retrieval from a mail client to a mail server. This is the reason why the need of POP or IMAP server and the SMTP servers at the time of configuring the email application.

4 :: Explain IMAP?

Short for Internet Message Access Protocol. This is another most prevalent protocol of internet standard for email usage apart from POP. Usually all the modern email server and client supports these two protocols for transmitting the email messages. For Example Gmail server uses to transmit the message to a client such as Mozilla Thunderbird and Microsoft Outlook.

IMAP is an application layer protocol over internet that is operating from port no. 143 that allows the accessibility of email on a remote server by a client. IMAP supports the online and offline (disconnected) modes of operations. Usually the email clients using IMAP utilizes the facility of leaving the message on the server. The message lasts until the user explicitly deletes them. IMAP also allows multiple clients to have the accessibility of the same mailbox.

5 :: Explain POP, SMTP and IMAP protocols?

SMTP (Simple Mail Transfer Protocol) allows two mail servers to communicate using a simple language, and provides a step-by-step protocol for exchanging information.
SMTP delivers mail to a central location, where the user can either log in and read it directly or use a client/server mail protocol to read it remotely.
IMAP (Internet Mail Access Protocol) is client/server mail protocol.
IMAP is designed to keep mail on a remote server and let the user interact with it there.
People with fast connections and multiple machines usually use IMAP so they can read mail from whichever machine they happen to be on without losing access to the mail they read elsewhere.
POP3 (Post Office Protocol Version 3) is client/server mail protocol.
It is designed to forward a user's mail to a single machine, where the user can go offline and read it, if necessary.
In general, people with slow connections (dial-up or otherwise) tend to use POP3 because they can connect and download their mail without having to keep the connection open afterwards.

6 :: What is the use of MIME within message makeup?

MIME message includes the picture stored as file in GIF format and the GIF format uses 8-bit format. The RFC 822 uses ASCII text format. The messages in the form of ASCII text format is to be encoded. To display the image in the recipient system, the information abut the encoding mechanism is used. The message is to be made up in the recipient’s application. The following snippet is used to identify the content is a GIF file which is to be encoded using the standard “base64Algorithm. This is to be treated as an attachment by the client who uses the email.

Content-Type: image/gif;
name="waterfall.gif"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="waterfall.gif"
[Author the encoded content here]
..

The accomplishment of this is done by simplifying and rebuilding of complex files. These files are encoded and transported as a body of the message or a series of messages which are the parts of the file.

A message format is defined by the MIME that allows the following:

Non ASCII character textual message bodies.
Non textual message bodies
Message bodies that are multipart
Non ASCII character textual header information

7 :: What is the structure of JavaMail API?

The JavaMail API has classes such as Message, Store and Transport. The API can be used to subclass for providing new protocols and some additional functionality when needed. The concrete subclasses of this API are MimeMessage and MimeBodyPart which are implemented widely by the internet mail protocols. The supporting protocols for Javamail API are IMAP4, POP3 and SMTP.

The Java mail architectural components include the following:

Abstract Layer: This layer declares the classes, interfaces and abstract methods that are intended for supporting the mail functions which all mailing systems supports.

Intranet Implementation Layer: The implementation of MIME internet standards and part of the abstract layer comprises this layer.

Java Bean Activation Framework: The encapsulation of message data and handling the data interacting commands is used by the Javabean Activation Framework.