emails a funcionar

git-svn-id: https://svn.coded.pt/svn/SIPRP@1165 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Diogo Neves 16 years ago
parent 5973e72b8e
commit 05eb853f82

@ -14266,12 +14266,8 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
private final String mail_bcc = "acidentes.auchan@siprp.pt"; private final String mail_bcc = "acidentes.auchan@siprp.pt";
private final String mail_bcc2 = "siprp.aat@evolute.pt"; private final String mail_bcc2 = "siprp.aat@evolute.pt";
public class SMTPAuthenticator extends Authenticator { private void sendEmail(String emailTo, String emailFrom, String assunto, String texto_email)
public PasswordAuthentication getPasswordAuthentication() { throws Exception
return new PasswordAuthentication( mail_username, mail_password );
}
}
private void sendEmail(String emailTo, String emailFrom, String assunto, String texto_email) throws Exception
{ {
Properties props = new Properties(); Properties props = new Properties();
//props.put("mail.transport.protocol", "smtp"); //props.put("mail.transport.protocol", "smtp");
@ -14280,8 +14276,8 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
props.put("mail.smtp.auth", "true"); props.put("mail.smtp.auth", "true");
props.put("mail.smtp.user", mail_username ); props.put("mail.smtp.user", mail_username );
props.put("mail.smtp.password", mail_password ); props.put("mail.smtp.password", mail_password );
// Session session1 = Session.getInstance(props);
Authenticator auth = new SMTPAuthenticator(); // Authenticator auth = new SMTPAuthenticator();
// Session session = Session.getDefaultInstance(props, auth); // Session session = Session.getDefaultInstance(props, auth);
Session session = Session.getDefaultInstance( props ); Session session = Session.getDefaultInstance( props );
@ -14361,19 +14357,26 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
"application/pdf"); "application/pdf");
Properties props = new Properties(); Properties props = new Properties();
//props.put("mail.transport.protocol", "smtp"); //props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", "mail2.evolute.pt"); props.put("mail.smtp.host", SMTP_HOST );
props.put("mail.from", emailFrom); props.put("mail.from", emailFrom);
props.put("mail.smtp.auth", "true"); props.put("mail.smtp.auth", "true");
props.put("mail.smtp.user", "lluis"); props.put("mail.smtp.user", mail_username );
props.put("mail.smtp.password", "654321"); props.put("mail.smtp.password", mail_password );
// Session session1 = Session.getInstance(props);
Authenticator auth = new SMTPAuthenticator(); // Authenticator auth = new SMTPAuthenticator();
Session session = Session.getDefaultInstance(props, auth); // Session session = Session.getDefaultInstance(props, auth);
Session session = Session.getDefaultInstance( props );
Message msg = new MimeMessage(session); Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(emailFrom)); msg.setFrom(new InternetAddress(emailFrom));
InternetAddress[] address = {new InternetAddress(emailTo)}; InternetAddress[] address = {new InternetAddress(emailTo)};
msg.setRecipients(Message.RecipientType.TO, address); msg.setRecipients(Message.RecipientType.TO, address);
InternetAddress[] addressBCC = new InternetAddress[ 2 ];
addressBCC[ 0 ] = new InternetAddress( mail_bcc );
addressBCC[ 1 ] = new InternetAddress( mail_bcc2 );
msg.setRecipients( Message.RecipientType.BCC, addressBCC );
((MimeMessage)msg).setSubject(assunto, "UTF-8"); ((MimeMessage)msg).setSubject(assunto, "UTF-8");
msg.setSentDate(new Date()); msg.setSentDate(new Date());
Multipart multipart = new MimeMultipart(); Multipart multipart = new MimeMultipart();

Loading…
Cancel
Save