no message

git-svn-id: https://svn.coded.pt/svn/SIPRP@503 bb69d46d-e84e-40c8-a05a-06db0d633741
lxbfYeaa
Frederico Palma 21 years ago
parent abad2911cb
commit 914ccbb840

@ -149,6 +149,56 @@ public class MailerServlet extends HttpServlet
return false;
}
protected boolean sendMail( String from, String destination, String subject, String content, boolean html,
String filename, byte attachment[] )
{
String smtp_server = "localhost";
String mailer = "Evolute Mailer";
Properties props = System.getProperties();
props.put( "mail.smtp.host", smtp_server );
String content_type = ( html ) ? "text/html" : "text/plain";
Session session = Session.getInstance( props, null );
Message msg = new MimeMessage( session );
try
{
if( from != null )
{
msg.setFrom( new InternetAddress( from ) );
}
msg.setRecipients( Message.RecipientType.TO, InternetAddress.parse( destination, true ) );
msg.setSubject( subject );
msg.setHeader( "X-Mailer", mailer );
msg.setSentDate( new java.util.Date() );
Multipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent( content.toString(), content_type );
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
// DataSource source = new ByteDataSource(attachment);
// messageBodyPart.setDataHandler(
// new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
msg.setContent(multipart);
Transport.send( msg );
return true;
}
catch( Exception e )
{
e.printStackTrace();
}
return false;
}
private String checkParameter( String parameter )
{

@ -0,0 +1,57 @@
/*
* RequestServlet.java
*
* Created on 4 de Março de 2005, 18:19
*/
package siprp.pagina;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*
* @author psantos
*/
public class RecruitServlet extends MailerServlet
{
private final static String REC_FUNCAO = "rec_funcao";
private final static String REC_NOME = "rec_nome";
private final static String REC_MORADA = "rec_morada";
private final static String REC_TELEFONE = "rec_telefone";
private final static String REC_EMAIL = "rec_email";
private final static String REC_CV = "rec_cv";
private final static String[] FORM_FIELDS = new String[]{
REC_FUNCAO, REC_NOME, REC_MORADA,
REC_TELEFONE, REC_EMAIL, REC_CV
};
public void doPost( HttpServletRequest req, HttpServletResponse res )
throws IOException
{
ServletOutputStream out = res.getOutputStream();
res.setContentType( "text/html" );
Hashtable parameters = parseParameters( new Hashtable( req.getParameterMap() ) );
String content = createContent( parameters, FORM_FIELDS, "mail/envio_cv.txt" );
String from = ( String ) parameters.get( REC_EMAIL );
String email = DEFAULT_EMAIL;
if( PROPERTIES != null && PROPERTIES.containsKey( EMAIL_RECRUTAMENTO ) )
{
email = ( String ) PROPERTIES.get( EMAIL_RECRUTAMENTO );
}
String destination = email;
String subject = "Envio de CV através do site www.siprp.pt";
// manda mail
boolean success = sendMail( from, destination, subject, content, false );
// mostra pagina correspondente
out.println( showResultPage( success, "mail/pedido_enviado.html", "mail/pedido_nao_enviado.html" ) );
}
}

@ -16,7 +16,7 @@ Esta página dá acesso a funcionalidades exclusivas e confidenciais
<span id='span_recrut_id' style="font-weight: bold; text-decoration: underline; cursor: pointer" onmousedown="return false;" onclick="showhide('recrut_id')">Junte-se a N&oacute;s</span><br>
<br>
<div id='recrut_id' style="display: none">
<form method='post' action='/siprpWeb/schedule' name='recrutamento' id='recrutamento'>
<form method='post' action='/siprpWeb/schedule' name='recrutamento' id='recrutamento' enctype='multipart/form-data'>
<table border='0' class='text'>
<tbody>
<tr>
@ -24,7 +24,7 @@ Esta p&aacute;gina d&aacute; acesso a funcionalidades exclusivas e confidenciais
Fun&ccedil;&atilde;o*:
</td>
<td>
<select name='funcao' id='funcao'>
<select name='rec_funcao' id='rec_funcao'>
<option VALUE='0'>T&eacute;cnico de Higiene e Seguran&ccedil;a</option>
<option VALUE='1'>T&eacute;cnico Superior de Higiene e Seguran&ccedil;a</option>
<option VALUE='2'>M&eacute;dico do Trabalho</option>
@ -39,7 +39,7 @@ Esta p&aacute;gina d&aacute; acesso a funcionalidades exclusivas e confidenciais
Nome Completo*:
</td>
<td>
<input type='text' id='nome' name='nome' size='50'>
<input type='text' id='rec_nome' name='rec_nome' size='50'>
</td>
</tr>
<tr>
@ -47,7 +47,7 @@ Esta p&aacute;gina d&aacute; acesso a funcionalidades exclusivas e confidenciais
Morada:
</td>
<td>
<input type='text' id='morada' name='morada' size='50'>
<input type='text' id='rec_morada' name='rec_morada' size='50'>
</td>
</tr>
<tr>
@ -55,7 +55,7 @@ Esta p&aacute;gina d&aacute; acesso a funcionalidades exclusivas e confidenciais
Telefone*:
</td>
<td>
<input type='text' id='telefone' name='telefone' size='10'>
<input type='text' id='rec_telefone' name='rec_telefone' size='10'>
</td>
</tr>
<tr>
@ -63,7 +63,15 @@ Esta p&aacute;gina d&aacute; acesso a funcionalidades exclusivas e confidenciais
E-Mail:
</td>
<td>
<input type='text' id='email' name='email' size='30'>
<input type='text' id='rec_email' name='rec_email' size='30'>
</td>
</tr>
<tr>
<td>
C.V.:
</td>
<td>
<input type='file' id='rec_cv' name='rec_cv'>
</td>
</tr>
<tr>

Loading…
Cancel
Save