41
WAP and E- WAP and E- mail mail by Neeraja Gudipati

WAP and E-mail WAP and E-mail by Neeraja Gudipati

Embed Size (px)

Citation preview

Page 1: WAP and E-mail WAP and E-mail by Neeraja Gudipati

WAP and E-mailWAP and E-mail

by

Neeraja Gudipati

Page 2: WAP and E-mail WAP and E-mail by Neeraja Gudipati

ContentsContents

Introduction to E-mail

Introduction to WAP

Why WAP and E-mail?

The Mail Process

Programming E-mail

WML class

A WAP-based E-mail Application

Page 3: WAP and E-mail WAP and E-mail by Neeraja Gudipati

E-MailE-Mail

• E-mail is an asynchronous message exchange technology.

• E-mail is a way for computer users to exchange messages, as long as there are networks such as the Internet connecting them. • E-mail the ‘killer app’ of the internet is more frequently used than even the web.

Page 4: WAP and E-mail WAP and E-mail by Neeraja Gudipati

WAPWAP

Wireless application protocol (WAP) is an application environment and set of communication protocols for wireless devices designed to enable manufacturer-, vendor-, and technology-independent access to the Internet and advanced telephony services.

Page 5: WAP and E-mail WAP and E-mail by Neeraja Gudipati

Why E-mail and WAP?Why E-mail and WAP?

•E-mail and WAP are fast becoming the most demanded combinations of technology by both corporations and general consumers.

•There were 569 million e-mail accounts globally at year-end 1999.

•It is predicted that there will be in excess of one billion e-mail accounts worldwide by 2002.

•There are currently 300 million mobile subscribers, growing at 50% per annum

•WAP penetration into the mobile phone market is predicted to be 8% in 2000, 22% in 2001, 50% in 2002 and 85% in 2003.

Page 6: WAP and E-mail WAP and E-mail by Neeraja Gudipati

The Mail ProcessThe Mail ProcessImportant mechanisms in the mail transport system:

Mail User Agent(MUA) - A program used to create and receive mail messages.

Mail Transfer Agent(MTA) - The means by which mail messages are transferred between machines over the internet

Mail Delivery Agent(MDA) - The mechanism that delivers the mail message to the recipient’s mailbox when mail is delivered via an MTA to the mail server

Page 7: WAP and E-mail WAP and E-mail by Neeraja Gudipati

Protocols usedProtocols usedThere are two types of protocol used in the e-mail process:

•Transport Protocols - Example: SMTP/ESMTP

•Storage and Retrieval protocols - Example: POP3/IMAP4

Page 8: WAP and E-mail WAP and E-mail by Neeraja Gudipati

A Typical E-Mail SystemA Typical E-Mail System

Directory Services

Mail Server

Mail Backbone

Mail ServerMail Server

Mail User Agent

SMTP/E-SMTP

POP3/IMAP

SMTP/E-SMTP

LDAPQuery

Page 9: WAP and E-mail WAP and E-mail by Neeraja Gudipati

Transmission path of e-mailTransmission path of e-mailSubmission E-SMTP

Transmission E-SMTP

Delivery File I/O

Retrieval POP/IMAP

Sender Mail User Agent (MUA)

Sending Mail Transfer Agent (MTA)

Destination Mail Transfer Agent (MTA)

INBOX Mail Delivery Agent (MDA)

Message Store

Recipient Mail User Agent (MUA)

Page 10: WAP and E-mail WAP and E-mail by Neeraja Gudipati

Programming E-mailProgramming E-mail

The Major API sets used to construct the Messaging Applications:

• Common Mail Calls

• Vendor Independent Messaging

• CDO and CDONTS

• JavaMail

Page 11: WAP and E-mail WAP and E-mail by Neeraja Gudipati

JavaMail:JavaMail:

JavaMail is platform-independent and protocol-independent, and therefore presents an ideal way to build e-mail and messaging solutions that will work with WAP technology

Advantages:

• It is available on the majority of current operating systems

• It offers an e-mail API that is both flexible and easy to use

• It offers excellent networking capabilities as standard

Page 12: WAP and E-mail WAP and E-mail by Neeraja Gudipati

WML ClassWML Class

•Encapsulates the details and logic needed by the servlet to generate a correctly formed WML page to send as the response to the user’s WAP browser request

•WML class models the formatting and header information needed to produce a valid WML document.

•Makes the generation of WML easier.

•Separates some of the WML syntax logic from the Java servlet code.

Page 13: WAP and E-mail WAP and E-mail by Neeraja Gudipati

WML Class WML Class Important Member FunctionsImportant Member Functions

/*Attributes

Stringbuffer buffer;

static final int deckSize = 1024

*/

/* Adds the card which has its id = iD to the deck*/

public void addCard(String iD)

/*Ends the card tag*/

public void endCard()

Page 14: WAP and E-mail WAP and E-mail by Neeraja Gudipati

Member functions (contd.)Member functions (contd.)

/*println appends the string line to the buffer of the WML class*/

public void println(String line)

/*outputWML gets the writer of the response and writes the contents of the buffer*/

/* if the disableCaching is true the caching of WAP pages is disabled */

public void outputWML(HttpServletResponse response, boolean disableCaching)

Page 15: WAP and E-mail WAP and E-mail by Neeraja Gudipati

WAP-based E-mail application WAP-based E-mail application --WAPMail--WAPMail

Implements a simple WAP mail system, allowing access to an SMTP/POP3-based e-mail account

Uses Java Servlets and JavaMail to:

•Compose, send and reply to mail via a SMTP server

•View an inbox and read mail using a POP3 service

•Determine the number of messages waiting in the inbox

•Delete mail

Page 16: WAP and E-mail WAP and E-mail by Neeraja Gudipati

WAPMail’s FunctionalityWAPMail’s Functionality

Splash Screen Login Screen

Main Menu

View inbox

Read Item

Delete

Reply

Send

Compose

Page 17: WAP and E-mail WAP and E-mail by Neeraja Gudipati

WAPMail.javaWAPMail.java

/* import statements */

import java.io.*;

import java.util.*;

import javax.mail.*;

import javax.mail.internet.*;

import javax.servlet.*;

import javax.servlet.http.*; //WAPMail extends HttpServlet

import com.wrox.util.WML; // WML class uses WML tags

Page 18: WAP and E-mail WAP and E-mail by Neeraja Gudipati

WAPMail.java(contd.)WAPMail.java(contd.)

public class WAPMail extends HttpServlet implements

SingleThreadModel{

/* Attributes */

private static String inboxString = “INBOX”;

private static UserSessionData _userSessionData;

Page 19: WAP and E-mail WAP and E-mail by Neeraja Gudipati

WAPMail.java(contd.)WAPMail.java(contd.)

/* Member Functions*/

public void doPost(HttpRequest request, HttpServletResponse response){

/* GET the session data */

UserSessionData userSessionData = getUserSessionData();

/* GET the action */

String action = request.getParameter(“action”);

Page 20: WAP and E-mail WAP and E-mail by Neeraja Gudipati

doPost FunctiondoPost Function/* SHOW SPLASH SCREEN */

if((action == null) || ((!action.equalsIgnoreCase(“login”)) &&(userSessionData == null))){

this.splashScreen(request,response,””);

}

/* LOGIN */

else if (action.equalsIgnoreCase(“login”)){

this.login(request, response);

}

// Similarly making decision for LOGOUT , SHOW MAIN MENU, //COMPOSE, SEND , VIEW INBOX , READ, DELETE , REPLY and //calling the corresponding functions

} /* end of doPost Function */

Page 21: WAP and E-mail WAP and E-mail by Neeraja Gudipati

splashScreen FunctionsplashScreen Functionpublic void splashScreen(HttpServletRequest request,

HttpServletResponse response, String message) {

/* Create an object of WML */

WML wml = new WML();

/* Add the card with id = WAPMailSplash */

wml.addCard("WAPMailSplash");

/* create a label Login, click activates the task */

wml.println(“<do type = “accept” label = “Login”>”);

/* in the case of the click action go the source of request */

wml.println(“<go href = “” + request.getRequestURI() + “” method = “post”>”);

/* post the request with action value = login */

wml.println(“<postfield name= "action" value= "login"/>”);

Page 22: WAP and E-mail WAP and E-mail by Neeraja Gudipati

splashScreen Function(contd.)splashScreen Function(contd.)// include postfield tags for posting uid and pwd

wml.println(“</go> + </do>”);

if(message != null){ /* generally true when there is an error */

//print the message

}

wml.println(“<p>” + “Username:” );

wml.println(“<input name=“uid” title=“user name”/> <br/>”);

wml.println(“Password:”);

wml.println("<input name="pwd" type="password" title="password"/><br/>” + “</p>”);

wml.endCard()’

wml.outputWML(response, true);

} /* end of splashScreen */

Page 23: WAP and E-mail WAP and E-mail by Neeraja Gudipati

Screen shot sequence of login Screen shot sequence of login processprocess

Page 24: WAP and E-mail WAP and E-mail by Neeraja Gudipati

login Functionlogin Function

public void login(HttpServletRequest request, HttpServletResponse response){

/* Get username */

String username = request.getParameter(“uid”);

/* Get password */

String password = request.getParameter(“pwd”);

// Get SMTP Session

// Get POP3 Session

// Get POP3 Store

Page 25: WAP and E-mail WAP and E-mail by Neeraja Gudipati

login Function(contd.)login Function(contd.)

// Create a new UserSessionData object

// if everything is ok show main menu

this.mainMenu(request, response, usd)

/* where usd is userSessionData */

} /* end of login function */

Page 26: WAP and E-mail WAP and E-mail by Neeraja Gudipati

mainMenu FunctionmainMenu Functionpublic void mainMenu(HttpServletRequest request, HttpServletResponse response, UserSessionData userSessionData){

WML wml = new WML();

/*Add the card with id = WAPMailMainMenu with the title

Main Menu */

wml.addCard("WAPMailMainMenu", "Main Menu");

wml.println("<anchor>1. Read Mail ”);

/* print the total number of messages in the inbox */

wml.println(this.getInboxCount(userSessionData));

wml.println(“<go href = request.getRequestURI());

Page 27: WAP and E-mail WAP and E-mail by Neeraja Gudipati

mainMenu Function(contd.)mainMenu Function(contd.)

wml.println(“?action=viewinbox"/>”);

wml.println(“</anchor><br/>”);

// Similar code for

// 2. Compose, action = compose

// 3. Logout , action = logout

wml.endCard();

wml.outputWML(response, true);

}

OUTPUT:

Page 28: WAP and E-mail WAP and E-mail by Neeraja Gudipati

viewInbox FunctionviewInbox Function

public void viewInbox(HttpServletRequest request,

HttpServletResponse response, UserSessionData userSessionData){

/* Get the inbox Folder */

Folder folder = userSessionData.getPop3Store().getFolder(inboxString);

/* Open the Folder in the READ_ONLY mode */

folder.open(Folder.READ_ONLY);

/* Get Directory */

Message message[] = folder.getMessages();

Page 29: WAP and E-mail WAP and E-mail by Neeraja Gudipati

viewInbox Function(contd.)viewInbox Function(contd.)

/* Get the number of messages in the folder */

int n = message.length;

WML wml = new WML();

wml.addCard("WAPMailViewInbox");

/* print inbox with the left alignment */

wml.println("<p align="left">");

wml.println("Inbox:<br/>");

Page 30: WAP and E-mail WAP and E-mail by Neeraja Gudipati

viewInbox Function(contd.)viewInbox Function(contd.)

// for each message print the From address , print the subject

// provide an anchor tag and go tag for read and delete to //link read and delete to their corresponding functions

wml.endCard();

wml.outputWML(response, true);

/* Close connection */

folder.close(false);

}

Page 31: WAP and E-mail WAP and E-mail by Neeraja Gudipati

read Functionread Function

public void read(HttpServletRequest request,

HttpServletResponse response, UserSessionData userSessionData){

// Get Folder i.e folder

// Get Message i.e. message

/* Get Content */

Object messageContent = message.getContent();

WML wml = new WML();

wml.addCard(“WAPMailReadMail”);

Page 32: WAP and E-mail WAP and E-mail by Neeraja Gudipati

read Function(contd.)read Function(contd.)

/* print From: ,the from address , the subject */

String emailAddress =

((InternetAddress)message.getFrom()[0]).getAddress();

wml.println("<p align="left">" +

"From: " + emailAddress + "<br/>" +

message.getSubject() + "<br/>" );

Page 33: WAP and E-mail WAP and E-mail by Neeraja Gudipati

read Function(contd.)read Function(contd.)

/* print the content of the mail if it is of type plain text else print error */

if(message.isMimeType(“text/plain”)&& messageContent instanceof String){

wml.println((String)messageContent);

}else{

wml.println(“Error! WAP Mail can only read plaintext e-mails”);

}

Page 34: WAP and E-mail WAP and E-mail by Neeraja Gudipati

read Function(contd.)read Function(contd.)

// provide an anchor tag and go tag for

// reply,delete, mainmenu and viewinbox

wml.endCard();

wml.outputWML(response, true);

folder.close(false);

} // end of read function

OUTPUT:

Page 35: WAP and E-mail WAP and E-mail by Neeraja Gudipati

logout Functionlogout Function

public void logout(HttpServletRequest request, HttpServletResponse response){

/* destroy the session data */

this.getUserSessionData().destroy();

/* make the session data null */

this. _userSessionData = null;

/* create a new WML object */

WML wml = new WML();

/* Add the card with id = WAPMailSplash */

wml.addCard("WAPMailLogout");

Page 36: WAP and E-mail WAP and E-mail by Neeraja Gudipati

logout Function(contd.)logout Function(contd.)wml.println("<p align="left">" +

"Thank you for using WAP Mail<br/>" +

"<anchor>Restart E-mail" +

"<go href="" + request.getRequestURI() + ""/>" +

"</anchor>" +

"</p>");

wml.endCard();

wml.outputWML(response, true);

} /* end of logout function */

} /* end of WAPMail class */

Page 37: WAP and E-mail WAP and E-mail by Neeraja Gudipati

Other FunctionsOther Functions•public void compose(HttpServletRequest request, HttpServletResponse response, String to, String subject)

•public void replyToMessage(HttpServletRequest request, HttpServletResponse response,UserSessionData userSessionData)•public void deleteMessage(HttpServletRequest request, HttpServletResponse response,UserSessionData userSessionData)

•public void send(HttpServletRequest request, HttpServletResponse response, UserSessionData userSessionData)

Page 38: WAP and E-mail WAP and E-mail by Neeraja Gudipati

Enhancements to WAPMailEnhancements to WAPMail

•Use HttpSession tracking to allow multi-user access to WAPMail.

•Allow the user to specify the POP3 and SMTP servers, perhaps allow for multiple accounts to be read.

•If the e-mail contains illegal WML characters, then the e-mail text needs to be parsed to ensure that we encounter no problems.

Page 39: WAP and E-mail WAP and E-mail by Neeraja Gudipati

FutureFuture

The ultimate goal for messaging technology is a universal inbox in which voice, fax and e-mail can be viewed in any format by a mobile communicator device.

Page 40: WAP and E-mail WAP and E-mail by Neeraja Gudipati

ReferencesReferences

• http://www.allnetdevices.com/developer/tutorials/2000/08/ 08/wap_and.html

• http://www.allnetdevices.com/developer/tutorials/2000/08/ 15/wap_and.html

• http://www.allnetdevices.com/developer/tutorials/2000/08/ 21/wap_and.html

• http://www.allnetdevices.com/developer/tutorials/2000/09/ 05/wap_and.html

• www.w3schools.com/wap

Page 41: WAP and E-mail WAP and E-mail by Neeraja Gudipati

QUESTIONS ??

E-mail : [email protected]