|
|
|
|
@ -13,15 +13,23 @@ import javax.mail.*;
|
|
|
|
|
import javax.mail.internet.*;
|
|
|
|
|
import javax.servlet.*;
|
|
|
|
|
import javax.servlet.http.*;
|
|
|
|
|
import java.sql.*;
|
|
|
|
|
|
|
|
|
|
import org.apache.velocity.*;
|
|
|
|
|
import org.apache.velocity.app.*;
|
|
|
|
|
|
|
|
|
|
import com.evolute.utils.arrays.*;
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @author psantos
|
|
|
|
|
*/
|
|
|
|
|
public class MailerServlet extends HttpServlet
|
|
|
|
|
implements GlobalConstants
|
|
|
|
|
{
|
|
|
|
|
public static final String EMAIL = "email";
|
|
|
|
|
|
|
|
|
|
protected static Hashtable PROPERTIES;
|
|
|
|
|
|
|
|
|
|
public void init()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
@ -32,6 +40,19 @@ public class MailerServlet extends HttpServlet
|
|
|
|
|
Properties props = new Properties();
|
|
|
|
|
props.setProperty( "file.resource.loader.path", TEMPLATE_DIR );
|
|
|
|
|
Velocity.init( props );
|
|
|
|
|
if( PROPERTIES == null )
|
|
|
|
|
{
|
|
|
|
|
Class.forName(bdDriver);
|
|
|
|
|
Connection con = DriverManager.getConnection( bdUrl, bdUsername, bdPassword );
|
|
|
|
|
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
|
|
|
|
|
ResultSet2DArray array = new ResultSet2DArray(
|
|
|
|
|
stmt.executeQuery( "Select name, value FROM properties;" ) );
|
|
|
|
|
PROPERTIES = new Hashtable();
|
|
|
|
|
for( int n = 0; n < array.columnLength(); n++ )
|
|
|
|
|
{
|
|
|
|
|
PROPERTIES.put( array.get( n, 0 ), array.get( n, 1 ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch( Exception e )
|
|
|
|
|
{
|
|
|
|
|
@ -113,7 +134,7 @@ public class MailerServlet extends HttpServlet
|
|
|
|
|
msg.setContent( content.toString(), content_type );
|
|
|
|
|
|
|
|
|
|
msg.setHeader( "X-Mailer", mailer );
|
|
|
|
|
msg.setSentDate( new Date() );
|
|
|
|
|
msg.setSentDate( new java.util.Date() );
|
|
|
|
|
Transport.send( msg );
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|