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
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