Paste the code below into a jsp, place ‘mail.jar’ and ‘activation.jar’ into the lib folder of a war.
<%@ page import="sun.net.smtp.SmtpClient, java.io.*" %> <% String from="xxx@hyve.com"; String to="xxx@hyve.com, xxx@hyve.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("It worked"); message.println(); message.println(); client.closeServer(); } catch (IOException e){ System.out.println("ERROR SENDING EMAIL:"+e); } %>
Tags:
JSP
One Response to Send email in Java
Warning: call_user_func() expects parameter 1 to be a valid callback, function 'twentyten_comment' not found or invalid function name in /var/www/html/wp-includes/class-walker-comment.php on line 184