Use javamail (on) in JSP)

Source: Internet
Author: User

Do you want to create an email sending and receiving tool in JSP? The following describes how to create an email sending and receiving tool in JSP. In this article, you will learn some key points of the javamail API and how to use it in JSP. This article also includes examples of using javamail in JSP. Javamail is a powerful API in JSP applications.

Reading this article requires a preliminary understanding of JSP, JavaBeans, and javamail. Of course, you can read this article to learn about javamail. If you do not know anything about the above three items, but the servers you use support JSP and javamail, you can simply use them by copying/pasting them.

What is javamail?

Javamail is an API released by Sun to process emails. It can easily perform some common mail Transmission.

Although javamail is one of Sun's APIs, it has not yet been added to the standard Java Development Kit (Java Development Kit), which means you must download the javamail file before use. In addition, you also need sun's JavaBeans activation framework (JAF ). The execution of the javamail activation framework is very complex. In this case, javamail must depend on its support. In Windows 2000, you must specify the path of these files, which is similar to that in other operating systems.

Next I will explain the most difficult part of this Guide.

This guide consists of three parts: HTML tables, javamail, javamail, and JSP.

Part 1: HTML table

The first section provides an example of the most basic HTML-based email sending and receiving program. The second part describes how javamail works. The third part introduces how to add javamail to JSP and create a basic email sending and receiving program.

Division Components

The most important feature of JSP is that it can divide the entire web page into small components. The components used here include:

● An HTML table used to send email information to JSP;

● A jsp page is used to process and send letters.

The first step is to create an HTML table to send information to the JSP page. You can copy the following HTML code to your computer:

HTML source code used to send emails

<HTML>
<Body>
<Form action = "sendmail. jsp" method = "Post">
<Table align = "center">
<Tr>
& Lt; TD width = "50%" & gt;
To: <br> <input name = "to" size = "25">
</TD>
& Lt; TD width = "50%" & gt;
From: <br> <input name = "from" size = "25">
</TD>
</Tr>
<Tr>
<TD colspan = "2">
Subject: <br> <input name = "subject" size = "50">
</TD>
</Tr>
<Tr>
<TD colspan = "2">
Message: <br> <textarea name = "text" rows = 25 Cols = 85> </textarea>
</TD>
</Tr>
</Table>
<Input type = "Submit" name = "cb_submit" value = "send">
<Input type = "reset" name = "cb_reset" value = "clear">
</Form>
</Body>
</Html>

The above process creates a file containing the basic email information (such as the receiving address, sending Address, subject, and content. Of course, you can decide the information contained in this file based on your own needs.

There are two requirements for the use of this HTML file: The first point is that the generated file must be sent to the program that will be introduced later. In this example, sendmail. jsp is used, but you must use the File URL in the system to replace it. Second, you must have space to allow users to send emails.

The second part analyzes the features of javamail to prepare for creating JSP programs in the third part. So next we will learn about javamail.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.