Category: General JSP

Paste the code below into a jsp, place ‘mail.jar’ and ‘activation.jar’ into the lib folder of a war.

<%@ page import=",*" %>
<% String from=""; String to=","; try{ SmtpClient client = new SmtpClient("localhost"); client.from(from);; 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("It worked"); message.println(); message.println(); client.closeServer(); } catch (IOException e){ System.out.println("ERROR SENDING EMAIL:"+e); } %>


0 0 vote
Article Rating



How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.