Java U4 C4
Java U4 C4
Programming
Prativa Nyaupane
Review
- Working with URLs and URL Connection Class
- Email Handling using Java Mail API
Outline
- TCP
- UDP
- IP Address
- Ports
- Socket Programming using TCP and UDP
- Working with URLs and URL Connection Class
- Email Handling using Java Mail API
- Architecture of RMI
- Creating and Executing RMI applications
- Architecture of CORBA
- RMI vs CORBA
- IDL and Simple CORBA Program
JavaMail Architecture
- The java application uses JavaMail
API to compose, send and receive
emails.
- The JavaMail API uses SPI(Service
Provider Interface) that provides
the intermediatory services to the
java application to deal with the
different protocols.
Steps of using Java Mail API
● Configure the mail server properties such as the host and port.
● Establish a mail session with the configured properties
● Pass authentication details if required.
● Construct an email message using the MimeMessage class.
● Set the sender, recipients, subject, and body of the email
● Use the Transport class to send the message
1. Mail User
SMTP Model Agent (MUA)
2. Mail
Submission
Agent (MSA)
3. Mail Transfer
Agent (MTA)
4. Mail Delivery
Agent (MDA)
Working of SMTP
Communication between the sender and the receiver :
● The sender’s user agent prepares the message and sends it to the MTA. The MTA’s responsibility is
to transfer the mail across the network to the receiver’s MTA.
● To send mail, a system must have a client MTA, and to receive mail, a system must have a server
MTA.
Sending Emails:
● Mail is sent by a series of request and response messages between the client and the server. The
message which is sent across consists of a header and a body. A null line is used to terminate the
mail header and everything after the null line is considered the body of the message, which is a
sequence of ASCII characters.
● The message body contains the actual information read by the receipt.
Receiving Emails:
● The user agent on the server-side checks the mailboxes at a particular time of intervals. If any
information is received, it informs the user about the mail.
● When the user tries to read the mail it displays a list of emails with a short description of each mail
in the mailbox. By selecting any of the mail users can view its contents on the terminal.