Example usage for org.apache.commons.mail HtmlEmail setSmtpPort

List of usage examples for org.apache.commons.mail HtmlEmail setSmtpPort

Introduction

In this page you can find the example usage for org.apache.commons.mail HtmlEmail setSmtpPort.

Prototype

public void setSmtpPort(final int aPortNumber) 

Source Link

Document

Set the port number of the outgoing mail server.

Usage

From source file:br.com.ezequieljuliano.argos.util.SendMail.java

public void send() throws EmailException {
    HtmlEmail email = new HtmlEmail();
    email.setHostName(server.getHostName());
    email.setAuthentication(server.getUser(), server.getPassWord());
    email.setSSL(server.isSSL());/*from  w ww. jav a 2s  .co  m*/
    email.setSmtpPort(server.getPort());

    for (Involved involved : recipients) {
        email.addTo(involved.getEmail(), involved.getName());
    }

    email.setFrom(sender.getEmail(), sender.getName());
    email.setSubject(subject);
    email.setHtmlMsg(message);
    email.setCharset("UTF-8");

    EmailAttachment att;
    for (Attachment annex : attachment) {
        att = new EmailAttachment();
        att.setPath(annex.getPath());
        att.setDisposition(EmailAttachment.ATTACHMENT);
        att.setDescription(annex.getDescription());
        att.setName(annex.getName());
        email.attach(att);
    }

    email.send();
}

From source file:Email.CommonsEmail.java

/**
 * funo para enviar email//from  w  w  w . jav a 2  s .co m
 *
 * @param titulo
 * @param msgEmail
 * @param emailDestinatarios
 * @return
 */
public boolean enviarEmail(String titulo, String msgEmail, String emailDestinatarios) {
    boolean enviado = false;
    String para = emailDestinatarios.toLowerCase().trim();
    String subject = titulo.trim();
    String msg = msgEmail.trim();

    try {
        StringTokenizer stPara = new StringTokenizer(para, ";");

        while (stPara.hasMoreTokens()) {
            if (!stPara.toString().trim().equals("")) {
                HtmlEmail email = new HtmlEmail();
                /*o servidor SMTP para envio do e-mail*/
                email.setHostName(emailConfig.getHostname());
                email.setSmtpPort(emailConfig.getPorta());
                email.setSSLOnConnect(emailConfig.getSsl());
                email.setStartTLSEnabled(emailConfig.getTsl());

                /*remetente*/
                email.setFrom(emailConfig.getEmail(), emailConfig.getNome());
                email.setAuthentication(emailConfig.getUsuario(), emailConfig.getSenha());
                /* ---------------------------------------------------------- */
                //destinatrio
                //email.addTo(emailDestinatario, nomeDestinatario);
                email.addTo(stPara.nextToken().trim());
                // assunto do e-mail
                email.setSubject(subject);

                //conteudo do e-mail
                //configura a mensagem para o formato HTML
                email.setHtmlMsg(msg);
                // configure uma mensagem alternativa caso o servidor no suporte HTML
                email.setTextMsg("Seu servidor de e-mail no suporta mensagem HTML");

                // envia email
                email.send();
                enviado = true;
            }
        }
    } catch (EmailException ex) {
        enviado = false;
        Logger.getLogger(CommonsEmail.class.getName()).log(Level.SEVERE, null, ex);
    }
    return enviado;
}

From source file:com.dattack.jtoolbox.commons.email.HtmlEmailBuilder.java

/**
 * Builder method.//  w w  w.  j ava 2s. c  o  m
 *
 * @return the HtmlEmail
 * @throws EmailException
 *             if an error occurs while creating the email
 */
public HtmlEmail build() throws EmailException {

    if (hostname == null || hostname.isEmpty()) {
        throw new EmailException(String.format("Invalid SMTP server (hostname: '%s')", hostname));
    }

    if (from == null || from.isEmpty()) {
        throw new EmailException(String.format("Invalid email address (FROM: '%s'", from));
    }

    final HtmlEmail email = new HtmlEmail();
    email.setHostName(hostname);
    email.setFrom(from);
    email.setSubject(subject);

    if (message != null && !message.isEmpty()) {
        email.setMsg(message);
    }

    if (port > 0) {
        email.setSmtpPort(port);
    }

    if (username != null && !username.isEmpty()) {
        email.setAuthenticator(new DefaultAuthenticator(username, password));
    }

    if (sslOnConnect != null) {
        email.setSSLOnConnect(sslOnConnect);
    }

    if (startTlsEnabled != null) {
        email.setStartTLSEnabled(startTlsEnabled);
    }

    if (!toList.isEmpty()) {
        email.setTo(toList);
    }

    if (!ccList.isEmpty()) {
        email.setCc(ccList);
    }

    if (!bccList.isEmpty()) {
        email.setBcc(bccList);
    }
    return email;
}

From source file:br.ufg.reqweb.components.MailBean.java

public void sendMailToDiscente(final Requerimento requerimento) {
    Thread sender = new Thread() {
        @Override//from  w  w  w  . jav  a 2s  . c  o m
        public void run() {
            try {
                Configuration templateConf = new Configuration();
                templateConf.setObjectWrapper(new DefaultObjectWrapper());
                templateConf.setDefaultEncoding("UTF-8");
                templateConf.setDirectoryForTemplateLoading(new File(context.getRealPath("/reports/mail")));
                Map objectRoot = new HashMap();
                objectRoot.put("TITULO", LocaleBean.getDefaultMessageBundle().getString("appTitle"));
                objectRoot.put("DISCENTE", LocaleBean.getDefaultMessageBundle().getString("discente"));
                objectRoot.put("REQUERIMENTO", LocaleBean.getDefaultMessageBundle().getString("requerimento"));
                objectRoot.put("STATUS", LocaleBean.getDefaultMessageBundle().getString("status"));
                objectRoot.put("ATENDENTE", LocaleBean.getDefaultMessageBundle().getString("atendente"));
                objectRoot.put("OBSERVACAO", LocaleBean.getDefaultMessageBundle().getString("observacao"));
                objectRoot.put("matricula", requerimento.getDiscente().getMatricula());
                objectRoot.put("discente", requerimento.getDiscente().getNome());
                objectRoot.put("tipoRequerimento", LocaleBean.getDefaultMessageBundle()
                        .getString(requerimento.getTipoRequerimento().getTipo()));
                objectRoot.put("status",
                        LocaleBean.getDefaultMessageBundle().getString(requerimento.getStatus().getStatus()));
                objectRoot.put("atendente", requerimento.getAtendimento().getAtendente().getNome());
                objectRoot.put("observacao", requerimento.getAtendimento().getObservacao());
                URL logo = new File(context.getRealPath("/resources/img/logo-mono-mini.png")).toURI().toURL();
                Template template = templateConf.getTemplate("notificacao_discente.ftl");
                Writer writer = new StringWriter();
                HtmlEmail email = new HtmlEmail();
                String logoId = email.embed(logo, "logo");
                objectRoot.put("logo", logoId);
                template.process(objectRoot, writer);
                email.setHostName(configDao.getValue("mail.mailHost"));
                email.setSmtpPort(Integer.parseInt(configDao.getValue("mail.smtpPort")));
                String mailSender = configDao.getValue("mail.mailSender");
                String user = configDao.getValue("mail.mailUser");
                String password = configDao.getValue("mail.mailPassword");
                boolean useSSL = Boolean.parseBoolean(configDao.getValue("mail.useSSL"));
                email.setAuthenticator(new DefaultAuthenticator(user, password));
                email.setSSLOnConnect(useSSL);
                email.setFrom(mailSender);
                email.addTo(requerimento.getDiscente().getEmail());
                email.setSubject(LocaleBean.getDefaultMessageBundle().getString("subjectMail"));
                email.setHtmlMsg(writer.toString());
                String alternativeMessage = String.format("%s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
                        LocaleBean.getDefaultMessageBundle().getString("messageMail"),
                        objectRoot.get("REQUERIMENTO"), objectRoot.get("tipoRequerimento"),
                        objectRoot.get("STATUS"), objectRoot.get("status"), objectRoot.get("ATENDENTE"),
                        objectRoot.get("atendente"), objectRoot.get("OBSERVACAO"),
                        objectRoot.get("observacao"));
                email.setTextMsg(alternativeMessage);
                email.send();
                System.out.println(String.format("message to discente:<%s: %s>",
                        requerimento.getDiscente().getNome(), requerimento.getDiscente().getEmail()));
            } catch (EmailException | IOException | TemplateException e) {
                System.out.println("erro ao enviar email");
                System.out.println(e);
            }
        }
    };
    sender.start();
}

From source file:com.ipc.service.SignUpService.java

public String sendhtmlmail(int uid, String key, String email) throws IOException, EmailException {
    HtmlEmail sendemail = new HtmlEmail();
    sendemail.setCharset("euc-kr");
    sendemail.setHostName("smtp.worksmobile.com");
    sendemail.addTo(email);/*from  w  ww. j av  a 2  s .c o m*/
    sendemail.setFrom("jinuk@ideaconcert.com", "");
    sendemail.setSubject("?  ?? ?.");
    sendemail.setAuthentication("jinuk@ideaconcert.com", "tpxmapsb1");
    sendemail.setSmtpPort(465);
    sendemail.setSSL(true); //?
    sendemail.setTLS(true);
    sendemail.setDebug(true);
    String htmlmsg = "<html><div style='width:1000px; float:left; border-bottom:2px solid #45d4fe; padding-bottom:5px;box-sizing:border-box;'></div><div style='width:1000px;float:left; box-sizing:border-box; padding:15px;'><h2>? ?  ? .</h2><div style='width:100%; float:left; box-sizing:border-box; border:5px solid #f9f9f9; text-align:center; padding:40px 0 40px 0;'><span>   ? .</span><br><a href='http://localhost:8088/signup/permit?uid="
            + uid + "&key=" + key
            + "'><button style='width:150px; height:40px; background:none; border:2px solid #45d4fe; font-size:1.1rem; text-decoration: none;font-weight:bold; margin-top:10px;'></button></a></div></div></html>";
    System.out.println(htmlmsg);
    sendemail.setHtmlMsg(htmlmsg);
    try {
        sendemail.send();
    } catch (Exception e) {
        System.out.println("NOTOK");
        return "NOTOK";
    }
    return "OK";
}

From source file:com.ipc.service.SignUpService.java

public String sendpwmail(int uid, String key, String email) throws IOException, EmailException {
    System.out.println("Email : " + email);
    HtmlEmail sendemail = new HtmlEmail();
    sendemail.setCharset("euc-kr");
    sendemail.setHostName("smtp.worksmobile.com");
    sendemail.addTo(email);//from   w  w w  .  j av  a 2  s .c om
    sendemail.setFrom("jinuk@ideaconcert.com", "");
    sendemail.setSubject("?  .");
    sendemail.setAuthentication("jinuk@ideaconcert.com", "tpxmapsb1");
    sendemail.setSmtpPort(465);
    sendemail.setSSL(true); //?
    sendemail.setTLS(true);
    sendemail.setDebug(true);
    String htmlmsg = "<html><div style='width:1000px; float:left; border-bottom:2px solid #45d4fe; padding-bottom:5px;box-sizing:border-box;'></div><div style='width:1000px;float:left; box-sizing:border-box; padding:15px;'><h2>?   .</h2><div style='width:100%; float:left; box-sizing:border-box; border:5px solid #f9f9f9; text-align:center; padding:40px 0 40px 0;'><span>  ?  <br> .<br>"
            + key + "</span></html>";
    System.out.println(htmlmsg);
    sendemail.setHtmlMsg(htmlmsg);
    try {
        sendemail.send();
    } catch (Exception e) {
        System.out.println("NOTOK");
        return "NOTOK";
    }
    return "OK";
}

From source file:br.com.atmatech.sac.controller.Email.java

public void emai(String smtp, String user, String password, Integer porta, Boolean ssl, Boolean tls,
        String emailto, String emailfrom, String conteudo, String assunto)
        throws EmailException, MalformedURLException {
    HtmlEmail email = new HtmlEmail();
    email.setHostName(smtp); // o servidor SMTP para envio do e-mail                  
    email.addTo(emailto);//destinatario            
    conteudo = conteudo.replaceAll("\n", "<p>");
    email.setFrom(emailfrom); // remetente        
    //email.addCc(emailfrom);
    email.setSubject(assunto);// w ww.  j  av a 2 s . c  om
    // configura a mensagem para o formato HTML        
    email.setHtmlMsg("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"
            + conteudo + "</html>");
    email.setAuthentication(user, password);
    email.setSmtpPort(porta);
    email.setSSL(ssl);
    email.setTLS(tls);
    email.send();
}

From source file:de.jaide.courier.email.MessageHandlerEMail.java

public void handleMessage(Map<String, Object> parameters) throws CourierException {
    /*// www . j  a  v a2  s .c  o  m
     * Check if the obligatory parameters are there.
     */
    for (String key : obligatoryMappingParameters)
        if (!parameters.containsKey(key))
            throw new CourierException(new MissingParameterException(
                    "The parameter '" + key + "' was expected but couldn't be found."));

    /*
     * Now retrieve the obligatory parameters.
     */
    String configurationName = (String) parameters.get(MAPPING_PARAM_CONFIGURATION_NAME);
    String templatePath = (String) parameters.get(MAPPING_PARAM_TEMPLATE_PATH);
    if ((templatePath != null) && (!templatePath.endsWith("/")))
        templatePath += "/";
    else if (templatePath == null)
        templatePath = "/";

    Class<?> templatePathClass = (Class<?>) parameters.get(MAPPING_PARAM_TEMPLATE_PATH_CLASS);
    File templatePathFile = (File) parameters.get(MAPPING_PARAM_TEMPLATE_PATH_FILE);

    String templateName = (String) parameters.get(MAPPING_PARAM_TEMPLATE_NAME);
    TemplateTypeEnum templateTypeEnum = (TemplateTypeEnum) parameters.get(MAPPING_PARAM_TEMPLATE_TYPE);
    String recipientFirstname = (String) parameters.get(MAPPING_PARAM_RECIPIENT_FIRSTNAME);
    String recipientLastname = (String) parameters.get(MAPPING_PARAM_RECIPIENT_LASTNAME);
    String recipientEMail = (String) parameters.get(MAPPING_PARAM_RECIPIENT_EMAIL);
    String ccRecipientFirstname = (String) parameters.get(MAPPING_PARAM_CC_RECIPIENT_FIRSTNAME);
    String ccRecipientLastname = (String) parameters.get(MAPPING_PARAM_CC_RECIPIENT_LASTNAME);
    String ccRecipientEMail = (String) parameters.get(MAPPING_PARAM_CC_RECIPIENT_EMAIL);

    /*
     * The next three parameters are optional, as they might also be specified in the SMTP configuration file. If they are specified they
     * tell us to overwrite what was specified in the SMTP configuration file and use those values (firstname, lastname, e-mail) for the
     * sender instead.
     */
    String senderFirstname = null;
    if (parameters.containsKey(MAPPING_PARAM_SENDER_FIRSTNAME))
        senderFirstname = (String) parameters.get(MAPPING_PARAM_SENDER_FIRSTNAME);

    String senderLastname = null;
    if (parameters.containsKey(MAPPING_PARAM_SENDER_LASTNAME))
        senderLastname = (String) parameters.get(MAPPING_PARAM_SENDER_LASTNAME);

    String senderEMail = null;
    if (parameters.containsKey(MAPPING_PARAM_SENDER_EMAIL))
        senderEMail = (String) parameters.get(MAPPING_PARAM_SENDER_EMAIL);

    /*
     * Will be used for parsing the templates.
     */
    StringWriter writer = new StringWriter();

    try {
        /*
         * Construct the template that we're about to process. First set the path to load the template(s) from. In case a Directory was given
         * as the base for template loading purposes use that instead.
         */
        if (templatePathFile == null) {
            if (templatePathClass == null)
                templatingConfiguration.setClassForTemplateLoading(getClass(), templatePath);
            else
                templatingConfiguration.setClassForTemplateLoading(templatePathClass, templatePath);
        } else
            templatingConfiguration.setDirectoryForTemplateLoading(templatePathFile);

        /*
         * Get the headers and Freemarker-parse them. If there are no headers then ignore the errors. The file has to be one header per line,
         * header name and value separated by a colon (":").
         */
        Template template;

        Map<String, String> headers = new HashMap<String, String>();
        String headersFilename = retrieveTemplateFilename(templateName,
                MessageHandlerEMail.TEMPLATENAME_SUFFIX_HEADERS, true);
        if (headersFilename != null) {
            try {
                template = loadTemplate(headersFilename);
                template.process(parameters, writer);
                BufferedReader reader = new BufferedReader(new StringReader(writer.toString()));
                headers = new HashMap<String, String>();
                String str = "";
                while ((str = reader.readLine()) != null) {
                    String[] split = str.split(":");
                    if (split.length > 1)
                        headers.put(split[0].trim(), split[1].trim());
                }
            } catch (IOException ioe) {
                // The header file is optional, hence we don't care if it couldn't be found
            }
        }

        /*
         * Get the subject line and Freemarker-parse it.
         */
        String subject = loadAndProcessTemplate(parameters, MessageHandlerEMail.TEMPLATENAME_SUFFIX_SUBJECT,
                templateName, false);

        /*
         * Get the body content and Freemarker-parse it.
         */
        String contentText = null;
        String contentHtml = null;

        /*
         * Load all requested versions of the template.
         */
        if (templateTypeEnum == TemplateTypeEnum.TEXT) {
            contentText = loadAndProcessTemplate(parameters, MessageHandlerEMail.TEMPLATENAME_SUFFIX_BODY,
                    templateName, false);
        } else if (templateTypeEnum == TemplateTypeEnum.HTML) {
            contentHtml = loadAndProcessTemplate(parameters, MessageHandlerEMail.TEMPLATENAME_SUFFIX_BODY,
                    templateName, true);
        } else if (templateTypeEnum == TemplateTypeEnum.BOTH) {
            contentText = loadAndProcessTemplate(parameters, MessageHandlerEMail.TEMPLATENAME_SUFFIX_BODY,
                    templateName, false);
            contentHtml = loadAndProcessTemplate(parameters, MessageHandlerEMail.TEMPLATENAME_SUFFIX_BODY,
                    templateName, true);
        } else if (templateTypeEnum == TemplateTypeEnum.ANY) {
            try {
                contentText = loadAndProcessTemplate(parameters, MessageHandlerEMail.TEMPLATENAME_SUFFIX_BODY,
                        templateName, false);
            } catch (IOException ioe) {
            } finally {
                try {
                    contentHtml = loadAndProcessTemplate(parameters,
                            MessageHandlerEMail.TEMPLATENAME_SUFFIX_BODY, templateName, true);
                } catch (IOException ioe) {
                    throw new RuntimeException(
                            "Neither the HTML nor the TEXT-only version of the e-mail template '" + templateName
                                    + "' could be found. Are you sure they reside in '" + templatePath
                                    + "' as '" + templateName + "_body.ftl.html' or '" + templateName
                                    + "_body.ftl.txt'?",
                            ioe);
                }
            }
        }

        /*
         * Set the parameters that are identical for that sender, for all recipients.
         * Note: attachments may not be removed once they have been attached, hence the performance-improving caching had to be removed.
         */
        SmtpConfiguration smtpConfiguration = (SmtpConfiguration) smtpConfigurations.get(configurationName);
        HtmlEmail htmlEmail = new HtmlEmail();
        htmlEmail.setCharset("UTF-8");
        htmlEmail.setHostName(smtpConfiguration.getSmtpHostname());
        htmlEmail.setSmtpPort(smtpConfiguration.getSmtpPort());
        if (smtpConfiguration.isTls()) {
            htmlEmail.setAuthenticator(
                    new DefaultAuthenticator(smtpConfiguration.getUsername(), smtpConfiguration.getPassword()));
            htmlEmail.setStartTLSEnabled(smtpConfiguration.isTls());
        }
        htmlEmail.setSSLOnConnect(smtpConfiguration.isSsl());

        /*
         * Changing the sender, to differ from what was specified in the particular SMTP configuration, is optional. As explained above this
         * will only happen if they were specified by the caller.
         */
        if ((senderFirstname != null) || (senderLastname != null) || (senderEMail != null))
            htmlEmail.setFrom(senderEMail, senderFirstname + " " + senderLastname);
        else
            htmlEmail.setFrom(smtpConfiguration.getFromEMail(), smtpConfiguration.getFromSenderName());

        /*
         * Set the parameters that differ for each recipient.
         */
        htmlEmail.addTo(recipientEMail, recipientFirstname + " " + recipientLastname);
        if ((ccRecipientFirstname != null) && (ccRecipientLastname != null) && (ccRecipientEMail != null))
            htmlEmail.addCc(ccRecipientEMail, ccRecipientFirstname + " " + ccRecipientLastname);
        htmlEmail.setHeaders(headers);
        htmlEmail.setSubject(subject);

        /*
         * Set the HTML and Text version of the e-mail body.
         */
        if (contentHtml != null)
            htmlEmail.setHtmlMsg(contentHtml);
        if (contentText != null)
            htmlEmail.setTextMsg(contentText);

        /*
         * Add attachments, if available.
         */
        if (parameters.containsKey(MAPPING_PARAM_ATTACHMENTS)) {
            @SuppressWarnings("unchecked")
            List<EmailAttachment> attachments = (List<EmailAttachment>) parameters
                    .get(MAPPING_PARAM_ATTACHMENTS);
            for (EmailAttachment attachment : attachments) {
                htmlEmail.attach(attachment);
            }
        }

        /*
         * Finished - now send the e-mail.
         */
        htmlEmail.send();
    } catch (IOException ioe) {
        throw new CourierException(ioe);
    } catch (TemplateException te) {
        throw new CourierException(te);
    } catch (EmailException ee) {
        throw new CourierException(ee);
    } finally {
        if (writer != null) {
            writer.flush();

            try {
                writer.close();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }
    }
}

From source file:com.smi.travel.util.Mail.java

public String sendmailwithAttchfile(String sendTo, String subject, String content, String attachfile,
        String sendCc) throws EmailException {
    String result = "";
    boolean send = false;
    EmailAttachment attachment = new EmailAttachment();
    HtmlEmail email = new HtmlEmail();
    try {/*  w  w  w  . jav a 2s  .  c  o  m*/
        if ((attachfile != null) && (!attachfile.equalsIgnoreCase(""))) {
            //attachment.setPath("C:\\Users\\Surachai\\Documents\\NetBeansProjects\\SMITravel\\test.txt");
            attachment.setPath(attachfile);
            attachment.setDisposition(EmailAttachment.ATTACHMENT);
            attachment.setDescription("file attachment");
            attachment.setName("text.txt");
            email.attach(attachment);
        }
        send = true;
    } catch (EmailException ex) {
        System.out.println("Email Exception");
        ex.printStackTrace();
        result = "fail";
    }
    if (send) {
        System.out.println(mail.getUsername() + mail.getPassword());
        email.setHostName(mail.getHostname());
        email.setSmtpPort(mail.getPort());
        email.setAuthentication(mail.getUsername(), mail.getPassword());
        email.setSSLOnConnect(true);
        email.setFrom(mail.getUsername());
        email.setSubject(subject);
        email.setHtmlMsg(content);
        String[] toSplit = sendTo.split("\\,");
        for (int i = 0; i < toSplit.length; i++) {
            System.out.println("Print toSplit" + toSplit[i]);
            email.addTo(toSplit[i]);
        }
        if (!sendCc.isEmpty()) {
            String[] ccSplit = sendCc.split("\\,");
            for (int i = 0; i < ccSplit.length; i++) {
                System.out.println("Print ccSplit" + ccSplit[i]);
                email.addCc(ccSplit[i]);
            }
        }
        email.send();

        result = "success";

    }
    return result;
}

From source file:br.com.atmatech.sac.controller.Email.java

public void emaiMassa(String smtp, String user, String password, Integer porta, Boolean ssl, Boolean tls,
        List<PessoaBeans> emailto, String emailfrom, String conteudo, String assunto)
        throws EmailException, MalformedURLException {
    HtmlEmail email = new HtmlEmail();
    email.setHostName(smtp); // o servidor SMTP para envio do e-mail
    Integer indice2 = 0;/*from w  w w  .j  a va2  s . c  o m*/
    Integer j = 0;
    for (int i = 0; (i < emailto.size()) && (i < 45); i++) {
        email.addTo(emailto.get(i).getEmail());//destinatario            
        indice2 = i;
    }
    while (j <= indice2) {
        emailto.remove(0);
        j++;
    }
    conteudo = conteudo.replaceAll("\n", "<p>");
    email.setFrom(emailfrom); // remetente        
    //email.addCc(emailfrom);
    email.setSubject(assunto);
    // configura a mensagem para o formato HTML        
    email.setHtmlMsg("<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"
            + conteudo + "</html>");
    email.setAuthentication(user, password);
    email.setSmtpPort(porta);
    email.setSSL(ssl);
    email.setTLS(tls);
    email.send();
    if (emailto != null) {
        if (emailto.size() > 1) {
            emaiMassa(smtp, user, password, porta, ssl, tls, emailto, emailfrom, conteudo, assunto);
        }
    }

}