List of usage examples for org.apache.commons.mail Email addTo
public Email addTo(final String... emails) throws EmailException
From source file:br.fgv.util.EmailSender.java
public static void enviarEmail(String body, String subject) throws EmailException { StringBuffer sb = new StringBuffer(""); sb.append(body);//from w w w .ja v a 2 s. c o m Email email = new SimpleEmail(); email.setHostName("smtp.gmail.com"); email.setDebug(true); email.setSSLOnConnect(true); email.addTo("wesley.seidel@gmail.com"); email.setAuthentication("wseidel.fgv", "batavinhofgv"); email.setFrom("wseidel.fgv@gmail.com"); email.setSubject(subject); email.setMsg(sb.toString()); email.send(); }
From source file:com.aprodher.actions.util.EmailUtils.java
public static void enviaEmail(Mensaje mensagem) throws EmailException { Email email = new SimpleEmail(); email = conectaEmail();//from ww w .j av a 2 s. c om email.setSubject(mensagem.getTitulo()); email.setMsg(mensagem.getMensagem()); email.addTo(mensagem.getDestino()); String resposta = email.send(); JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("emailenviado") + resposta); }
From source file:gsn.utils.services.EmailService.java
/** * This method cover most of the cases of sending a simple text email. If the email to be sent has to be configured * in a way which is not possible whith the parameters provided (such as html email, or email with attachement, ..), * please use the {@link #sendCustomEmail(org.apache.commons.mail.Email)} method and refer the API * {@see http://commons.apache.org/email/}. * * @param to A set of destination email address of the email. Must contain at least one address. * @param object The subject of the email. * @param message The msg of the email./*from w w w . j av a 2 s .co m*/ * @return true if the email has been sent successfully, false otherwise. */ public static boolean sendEmail(ArrayList<String> to, String object, String message) { Email email = new SimpleEmail(); try { email.setSubject(object); email.setMsg(message); if (to != null) for (String _to : to) email.addTo(_to); sendCustomEmail(email); return true; } catch (EmailException e) { logger.warn( "Please, make sure that the SMTP server configuration is correct in the file: " + SMTP_FILE); logger.error(e.getMessage(), e); return false; } }
From source file:com.reizes.shiva.net.mail.EmailSender.java
public static String sendMail(String host, int port, String from, String to, String subject, String text) throws IOException, EmailException { if (to != null && host != null) { String[] emailTo = StringUtils.split(to, ';'); Email email = new SimpleEmail(); email.setHostName(host);// www.ja v a 2 s . c o m email.setSmtpPort(port); email.setFrom(from); for (String recv : emailTo) { email.addTo(recv); } email.setSubject(subject); email.setMsg(text); return email.send(); } return null; }
From source file:io.jhonesdeveloper.swing.util.EmailUtil.java
public static void sendBasicText(String hostName, String username, String password, String from, String subject, String msg, String[] to) throws EmailException { Email email = new SimpleEmail(); email.setHostName(hostName);//from ww w .j av a 2 s . com email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(username, password)); email.setSSLOnConnect(true); email.setFrom(from); email.setSubject(subject); email.setMsg(msg); email.addTo(to); email.send(); }
From source file:de.alpharogroup.message.system.service.CommonsEmailSendService.java
public static void sendEmail(final EmailConfiguration config, InfoMessageModel model) throws EmailException { // TODO make class for email config... Email email = new SimpleEmail(); email.setHostName(config.getHostName()); email.setSmtpPort(config.getSmtpPort()); email.setFrom(model.getApplicationSenderAddress()); email.setSubject(model.getMessageContentModel().getSubject()); email.setMsg(model.getMessageContentModel().getContent()); email.addTo(model.getRecipientEmailContact()); email.send();/*from w ww. j a va2 s . c o m*/ }
From source file:at.tugraz.kmi.medokyservice.ErrorLogNotifier.java
public static void errorEmail(String msg) { Email email = new SimpleEmail(); email.setHostName("something.com"); email.setSmtpPort(465);/*from www.j a va 2 s .c o m*/ DefaultAuthenticator auth = new DefaultAuthenticator("username", "pwd"); email.setAuthenticator(auth); email.setSSLOnConnect(true); try { email.setFrom("email address"); email.setSubject("[MEDoKyService] Error"); email.setMsg(msg); email.addTo("yourmail.com"); email.send(); } catch (EmailException e) { e.printStackTrace(); } }
From source file:com.webbfontaine.valuewebb.irms.action.mail.MailActionHandler.java
private static void addRecipients(Email email, List<String> recipients) throws EmailException { for (String recipient : recipients) { List<String> newRcpts = Arrays.asList(COMPILE.split(recipient)); if (newRcpts.size() == 1) { email.addTo(newRcpts.get(0).trim()); } else {/*from w ww . j av a 2 s . c om*/ addRecipients(email, newRcpts); } } }
From source file:connection.EmailSending.java
public static void sendTextEmail(String subject, String content, String recipientEmail) { Email email = new SimpleEmail(); email.setHostName(MailInfor.HOST_NAME); email.setSmtpPort(465);//from w w w . ja v a2 s .c om email.setAuthenticator(new DefaultAuthenticator(MailInfor.EMAIL_SENDER, MailInfor.PASSWORD)); email.setSSLOnConnect(true); try { email.setFrom(MailInfor.EMAIL_SENDER); email.setSubject(subject); email.setMsg(content); email.addTo(recipientEmail); email.send(); } catch (EmailException ex) { Logger.getLogger(EmailSending.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ar.com.pahema.utils.MailSender.java
public static void enviar(String destino, Paquete paquete) throws EmailException { try {/*w w w .java 2 s . c o m*/ Email mail = new SimpleEmail(); //Configuracion necesaria para GMAIL mail.setHostName("mail.pahema.com.ar"); //mail.setTLS(true); mail.setSmtpPort(25); //mail.setSSL(true); //En esta seccion colocar cuenta de usuario de Gmail y contrasea mail.setAuthentication("dante@pahema.com.ar", "Fuerza2015"); //Cuenta de Email Destino // AC? IRIA LA DE ADMINISTRACION DE PAHEMA. mail.addTo("dante.gs@hotmail.com"); mail.addTo(destino); //Cuenta de Email Origen, la misma con la que nos autenticamos mail.setFrom("dante@pahema.com.ar", "Pahema - Sistema Tango"); //Titulo del Email mail.setSubject("Aviso de finalizacin de paquete de horas."); //Contenido del Email mail.setMsg("Estimado cliente,\n" + "Le informamos que su paquete de " + (int) paquete.getCantidadHoras() + " horas est por finalizar.\n" + "Le quedan por usar: " + (int) paquete.getHorasRestantes() + " horas.\n" + "Por favor comunquese con Pahema para el detalle de sus consumos: 4952 - 4789.\n" + "Muchas gracias.\n" + "Administracin."); mail.send(); } catch (EmailException e) { System.out.println(e.getMessage()); throw new RuntimeException("Ocurrio un error en el envio del mail"); } }