|
•10 Tips for Killer Website Design
•7 Sure shots ways to improve your website
•Attracting Visitors and Improving Your Search Results
•Chasing the Search Engines Algorithms
•Crash Course in Getting a 1 Google Ranking
•Design Basics
•Design Your Site for Traffic in 2005
•Designing A Website That Sells
•Googles Good Writing Content Filter
•How to Write Effective Web Copy
•How to Write Title Tags for Your Web Pages
•JSP
•JSP Actions
•JSP Directives
•JSP Scripting Elements and Variables
•JavaBeans
•Java Brewing A Tutorial
•Java How to Send Email in Java
•Java Intro to JSP
•Java JSP Browser Detection
•Java JSP Syntax
•Java JSP versus ASP
•Java MySQL Database Connection
•Java Programming Language
•Java Virtual Machine
•Java myths
•Linux Commands
•Make Money Fast With Google Adwords
•Make Money On The Internet What Is Your Niche
•Make Money Quick With Google Adsense
•PHP Redirects
•Ranked 1 at Google for Invisible Entrepreneurs But No Traffic
•Ruby Basic Input Output
•Ruby Classes Objects and Variables
•Ruby Containers Blocks and Iterators
•Ruby and the Web
•SEO One Way Web Links 5 Strategies
•SEO Success Step Two - Attracting Search Engine Attention
•The 10 Best Resources for CSS
•The 3 Best Website Traffic Sources
•The 5 Biggest Mistakes Almost All Web Designers Make
•The Click Fraud Problem
•The Five Ways You Should Be Using Keywords
•The Three Principles Of Image Optimization
•Top 5 Secrets to Making Money with Adsense
•True Paid Inclusion Programs are a Thing of the Past
•Understanding Web Logs And Why it Matters
•Index
•Temp
|
Web Hosting Tips for Webmasters -
How to Send Email in Java
- Using javax.mail (JSP)
- Using javax.mail (Servlet)
- Using sun.net.smtp.SmtpClient
Sample JSP EMAIL Application Page Using javax.mail
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.host", "localhost");
Session s = Session.getInstance(props);
// s.setDebug(true) ;
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("support@MyDomain.net");
message.setFrom(from);
InternetAddress to = new InternetAddress("support@YourDomain.net");
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
Transport.send(message);
%>
<html>
<p align="center">A Message has been sent.<br>Check your inbox.</p>
<p align="center"><a href="mailjavax.jsp">Click here to send another!</a></p>
</html>
Sample Servlet EMAIL Application Page Using javax.mail
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class AHMail extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"\n";
out.println(docType +
"\n" +
"Hello\n" +
"\n" );
Properties props = new Properties();
out.println("props.put ");
props.put("mail.smtp.host", "localhost");
Session s = Session.getInstance(props);
out.println("Session.getInstance ");
try {
MimeMessage message = new MimeMessage(s);
InternetAddress from = new InternetAddress("support@YouDomain.com");
message.setFrom(from);
InternetAddress to = new InternetAddress("Customer@AOL.com");
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("Test from JavaMail.");
message.setText("Hello from JavaMail!");
Transport.send(message);
out.println("Transport.send ALL DONE ");
out.println(" " );
} catch (Exception ex) {
ex.printStackTrace();
out.println("exception: " + ex.getMessage() );
}
}
}
Sample JSP EMAIL Application Page Using sun.net.smtp.SmtpClient
<html>
<head>
<title>Sample EMAIL Application JSP Page </title>
</head>
<%@ page import="sun.net.smtp.SmtpClient, java.io.*" %>
<%
String from="dennis@TESTINGhosting.com";
String to="test@TESTINGhosting.com";
try{
SmtpClient client = new SmtpClient("localhost");
client.from(from);
client.to(to);
PrintStream message = client.startMessage();
message.println("To: " + to);
message.println("Subject: Sending email from JSP!");
message.println("This was sent from a JSP page!");
message.println();
message.println("Cool beans! :-)");
message.println();
message.println();
client.closeServer();
}
catch (IOException e){
System.out.println("ERROR SENDING EMAIL:"+e);
}
%>
</body>
</html>
|