Error opening link in Chrome and IE browsers

-1

I'm using JavaMail to send link to reset password, however, when I click the link and it only opens in Firefox, I can not open it in Chrome and IE, only if I copy the link and put in the URL, why this? Is it the Exchenge's fault? Or development error?

    
asked by anonymous 01.04.2016 / 16:47

1 answer

-1

@Service public class SendEmailServicoImpl implements SendEmailService {

@Override
public void enviarEmail(String id) {

    String destinatarioEmail = null;

    Properties props = new Properties();
    props.put("mail.smtp.host", "192.168.4.71");
    props.put("mail.smtp.socketFactory.port", "25");
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.auth", "false");
    props.put("mail.smtp.port", "25");

    Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {

        protected PasswordAuthentication getPasswordAuthentication() {
            return null;
        }
    });
    session.setDebug(true);

    FabricaConexao fabricaConexao = new FabricaConexao();

    @SuppressWarnings("static-access")
    Connection connection = fabricaConexao.getConexao();

    String sql = "select fun_email from tbl_funcionario where fun_codigo = ?";

    try {
        PreparedStatement statement = connection.prepareStatement(sql);
        statement.setString(1, id);
        ResultSet resultSet = statement.executeQuery();

        while (resultSet.next()) {
            Funcionario fun = new Funcionario();
            fun.setEmail(resultSet.getString("fun_email"));
            destinatarioEmail = fun.getEmail();
        }
    } catch (SQLException sE) {
        FacesUtil.adicionaMensagemErro("Erro no SQL: " + sE);
    } catch (Exception ex) {
        FacesUtil.adicionaMensagemErro("Erro :" + ex);
    }

    String remetente = "[email protected]"; // email do administrador
    String destinatario = destinatarioEmail; // email do funcionario que
                                                // solicitou nova senha

    try {
        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress(remetente)); // Remetente
        Address[] toUser = InternetAddress.parse(destinatario); // Destinatarios
        message.setRecipients(Message.RecipientType.TO, toUser);
        message.setSubject("Criar nova senha"); // assunto
        message.setContent(
                "Você solicitou a criar uma nova senha de acesso, para criar nova senha clique no link abaixo: <br/>"
                        + "<html><a href=\"localhost:8080/sgc/pages/gerarSenha.xhtml?id=" + id + "\">"
                        + "Clique aqui</a> <br/><p>Atenciosamente, </br>SISCORP<br/>Instituto </p></html>",
                "text/html");
        Transport.send(message);
        FacesUtil.adicionaMensagemInfo("Um link foi enviado para o seu email para criar uma nova senha.");
        FacesUtil.redirecionarPagina("login.xhtml");
    } catch (Exception e) {
        FacesUtil.adicionaMensagemErro("Erro ao tentar enviar email: " + e);
    }

}

}

    
06.04.2016 / 15:20