diff --git a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java index eb5bb744..b9964977 100644 --- a/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java +++ b/trunk/AnaliseAcidentesTrabalho/src/java/analiseacidentestrabalho/AnaliseAcidenteTrabalho.java @@ -14266,12 +14266,8 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean { private final String mail_bcc = "acidentes.auchan@siprp.pt"; private final String mail_bcc2 = "siprp.aat@evolute.pt"; - public class SMTPAuthenticator extends Authenticator { - public PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication( mail_username, mail_password ); - } - } - private void sendEmail(String emailTo, String emailFrom, String assunto, String texto_email) throws Exception + private void sendEmail(String emailTo, String emailFrom, String assunto, String texto_email) + throws Exception { Properties props = new Properties(); //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.user", mail_username ); 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 ); @@ -14361,19 +14357,26 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean { "application/pdf"); Properties props = new Properties(); //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.smtp.auth", "true"); - props.put("mail.smtp.user", "lluis"); - props.put("mail.smtp.password", "654321"); -// Session session1 = Session.getInstance(props); - Authenticator auth = new SMTPAuthenticator(); - Session session = Session.getDefaultInstance(props, auth); + props.put("mail.smtp.user", mail_username ); + props.put("mail.smtp.password", mail_password ); + +// Authenticator auth = new SMTPAuthenticator(); +// Session session = Session.getDefaultInstance(props, auth); + Session session = Session.getDefaultInstance( props ); Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(emailFrom)); InternetAddress[] address = {new InternetAddress(emailTo)}; 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"); msg.setSentDate(new Date()); Multipart multipart = new MimeMultipart();