Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Then try this:</p> <pre><code>public void envioEmail(final String from, final String mailhost, final String user, final String password, final Boolean auth, final String destinatario, final String assunto, final String mensagem) throws MessagingException, IOException { new Thread(){ @Override public void run() { Properties props = System.getProperties(); if (mailhost != null) props.put("mail.smtp.host", mailhost); if (auth) props.put("mail.smtp.auth", "true"); props.setProperty("mail.smtp.starttls.enable", "true"); Authenticator authh = new Authenticator() { @Override public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(user, password); } }; javax.mail.Session session = javax.mail.Session.getInstance(props, authh); javax.mail.Message msg = new MimeMessage(session); try { msg.setFrom(new InternetAddress(from)); msg.setRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(destinatario)); msg.setSubject(assunto); msg.setSentDate(new Date()); msg.setText(mensagem); SMTPTransport t = (SMTPTransport) session.getTransport(ssl ? "smtps" : "smtp"); try { if (auth){ t.connect(mailhost, user, password); t.sendMessage(msg, msg.getAllRecipients()); }else{ t.connect(); t.sendMessage(msg, msg.getAllRecipients()); } } finally { t.close(); } flag = true; atualizaTelaConexao("E-Mail enviado com sucesso!", ctx); } catch (MessagingException e) { flag = false; atualizaTelaConexao("Erro ao enviar E-Mail! Verifique as configuracoes de e-mail", ctx); } } }.start(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload