How to do authentication and include the web page in the mail?

B

BB

Below is my sendmail jsp (I copied it from somewhere else and it works for
me). It fetches the message from another page and sends it to a email. The
problem is that the smtp needs authentication. How do I add the
authentication detail in this jsp? And, how do I include the web page
instead of plain text in the email to be sent just like how it appears in
the email text area when I hit "Send page by email". Thanks.


<%@ page import="sun.net.smtp.SmtpClient, java.io.*" %>
<%
String strParm = request.getParameter("Message");
String from="(e-mail address removed)";
String to="(e-mail address removed)";
try{
SmtpClient client = new SmtpClient("smtp.2.com");
client.from(from);
client.to(to);
PrintStream message = client.startMessage();
message.println("To: " + to);
message.println("Subject: New Mail");
message.println(strParm);
client.closeServer();
}
catch (IOException e){
System.out.println("ERROR SENDING EMAIL:"+e);
}
%>


_________________________________________________________________
¡¹ ª±®a¶K¤h´ú¸Õª©¥¿¦¡µn³õ! http://www.bet.com.hk ¡¹

¦øªA¾¹¦«ºÞ¤Î¯²¥ÎªA°È¡A¥Ñ Newsgroup.com.hk Limited ±M·~ºÞ²z¡C
¤ë¶O§C¦Ü $300 ¡A¸Ô±¡½Ð­P¹q 3078 6888
 
O

Oscar kind

In comp.lang.java.help BB said:
Below is my sendmail jsp (I copied it from somewhere else and it works for
me). It fetches the message from another page and sends it to a email.

This is a good start, if you know what part of the code does what.

The
problem is that the smtp needs authentication. How do I add the
authentication detail in this jsp? And, how do I include the web page
instead of plain text in the email to be sent just like how it appears in
the email text area when I hit "Send page by email".

The authentication needs to be added when you create the instance of
SmtpClient, so read the API for that class.

To include the web page instead of the plain text, you need to:
- have the HTML in strParm
- set the content type of the message to "text/html" (read the API
of SmtpClient to see if and how this is possible).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top