Error to open link in Chrome and IE browsers

Asked

Viewed 97 times

-1

I’m using Javamail to send a link to reset the password, but when I click on the link and it only opens in Firefox, I can’t open it in Chrome or IE, only if I copy the link and put it in the URL, does anyone know why? Is it Exchenge error? Or development error?inserir a descrição da imagem aqui

  • Add link button code block, it would facilitate the response.

  • It seems more like a problem with your email client. Which server do you use where xhtml is?

  • I put the code below...

1 answer

-1

@Service public class Envioemailservicoimpl Implements Envioemailservico {

@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);
    }

}

}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.