JAVA Commons SimpleEmail

1

My code does not release any exception, but it does not send the email either, I've tried several possibilities, I think there may be some logic error:

<form method="POST" action="sendEmail.do">
                             <legend style="color: #fff">Fale Conosco</legend>  
                             <fieldset>
                             <div class="form-group">
                             <label class="control-label">Nome
                             <input type="text" class="form-control" name="nome">
                             </label>
                             </div>

                             <div class="form-group">
                             <label class="control-label">Email
                             <input type="email" class="form-control" name="email">
                             </label>
                             </div>  

                             <div class="form-group">
                             <label class="control-label">Telefone
                             <input type="text" class="form-control" name="tel">
                             </label>
                             </div>  

                             <div class="form-group">
                             <label class="control-label">Mensagem
                                 <textarea class="form-control" size="1000" name="mens" cols="21" rows="10"></textarea>
                             </label>
                             </div>  

                             </fieldset>    

                             <button type="submit" class="btn btn-primary">Enviar</button> 

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {



    String nome=request.getParameter("nome");
    String email=request.getParameter("email");
    String tel=request.getParameter("tel");
    String message=request.getParameter("mens");

    EnviarMail mail=new EnviarMail();
    mail.enviar(nome,email,tel,message);


    RequestDispatcher rd=request.getRequestDispatcher("confirm.jsp");
    rd.forward(request, response);

}
public class EnviarMail {

    public EnviarMail(){


    }


    public void enviar(String nome,String email,String tel,String msg){

        SimpleEmail newemail=new SimpleEmail();

        newemail.setHostName("smtp.gmail.com");
        newemail.setSmtpPort(465);

        try {

            newemail.setFrom("[email protected]");
            newemail.addTo("[email protected]");
            newemail.setSubject("ContatoFaleConosco");
            newemail.setMsg(nome);
            newemail.setMsg(email);
            newemail.setMsg(tel);
            newemail.setMsg(msg);
            newemail.setSSLOnConnect(true);
            newemail.setAuthentication("[email protected]","********");
            newemail.setDebug(true);
            newemail.send();


        } catch (EmailException ex) {
            Logger.getLogger(EnviarMail.class.getName()).log(Level.SEVERE, null, ex);
        }


     }     
}
    
asked by anonymous 26.10.2017 / 03:24

0 answers