Send Email In JSP#

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);
  }
%>

Back to JSP

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-2) was last changed on 24-May-2017 15:30 by Hyve Support
G’day (anonymous guest) My Prefs
  • View Page Source
  • This clear IPSec security association,
    clear ipsec sa peer X.X.X.X
    

All Pages

Page views: 2083

Private Tomcat

Linux

MySQL

Email

SQL Server

ASP

JSP

C#

Web Mail

Windows Plesk

Linux Plesk

PHP

Gaming

ASP.NET

Persits ASPUpload

Wiki Help

Referring Pages:
...nobody

JSPWiki v2.8.1