List of usage examples for org.apache.commons.mail Email setSubject
public Email setSubject(final String aSubject)
From source file:ar.com.pahema.utils.MailSender.java
public static void enviar(String destino, Paquete paquete) throws EmailException { try {/*from www . j a va 2 s . co 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"); } }
From source file:controller.SendMailMachine.java
public static void sendMail(Cart cart, String recipientEmail) { Email email = new SimpleEmail(); email.setHostName(HOST_NAME);/* w ww . ja v a2 s. c o m*/ email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(EMAIL_SENDER, PASSWORD)); email.setSSLOnConnect(true); String subject = "Thng tin ha n"; String content = "\t\t\tTRUNG TM MUA SM BITTORRENT\n\nChi tit n hng ca bn: \n"; for (Map.Entry<Integer, Item> entrySet : cart.getCartItem().entrySet()) { Item item = entrySet.getValue(); content += item.getWatch().getName() + "\t\t\t\t\t\t" + item.getQuantity() + " x " + ((int) item.getWatch().getPrice()) + "000 VND\n"; } content += "Tng ha n: " + ((int) cart.sumPrice()) + "000 VND"; try { email.setFrom(EMAIL_SENDER); email.setCharset("UTF-8"); email.setSubject(subject); email.setMsg(content); email.addTo(recipientEmail); email.send(); } catch (EmailException ex) { ex.printStackTrace(); } }
From source file:br.com.utfpr.edu.br.agenda.ServicoMail.EnviaEmailSimpleMail.java
public void envio(String destino) { Email email = new SimpleEmail(); try {// w ww . j a v a 2s . c o m email.setSubject("Teste de Envio com Simple Mail"); email.addTo(destino); email.setMsg("Est na hora de realizar a manuteno do seu carro. Verifique os itens!"); mailer.send(email); } catch (EmailException ex) { System.out.println("Erro ao enviar com Simple Mail."); Logger.getLogger(EnviaEmailSimpleMail.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:jmockit.tutorial.domain.MyBusinessService.java
private void sendNotificationEmail(List<EntityX> items) throws EmailException { Email email = new SimpleEmail(); email.setSubject("Notification about processing of ..."); email.addTo(data.getCustomerEmail()); // Other e-mail parameters, such as the host name of the mail server, have defaults defined through external // configuration. String message = buildNotificationMessage(items); email.setMsg(message);/*w ww .j a va 2 s . c o m*/ email.send(); }
From source file:iddb.core.util.MailManager.java
public void sendMail(String subject, String template, String[] dest, Map<String, String> args) throws Exception { if (props == null) throw new Exception("Unable to access email subsystem."); try {/*from w w w. j a v a2 s. c om*/ Email email = new SimpleEmail(); email.setSubject(subject); email.setMsg(TemplateManager.getTemplate(template, args)); for (String adr : dest) { email.addTo(adr); } email.setCharset("ISO-8859-1"); setEmailProps(email); email.send(); } catch (Exception e) { log.error("{}: {}", e.getClass().getName(), e.getMessage()); throw new Exception("We are unable to send your message right now."); } }
From source file:iddb.core.util.MailManager.java
public void sendAdminMail(String subject, String message, String replyTo) throws Exception { if (props == null) throw new Exception("Unable to access email subsystem."); try {// w ww . j a v a 2 s. c om Email email = new SimpleEmail(); email.setSubject(subject); email.setMsg(message); if (replyTo != null) { email.addReplyTo(replyTo); } for (String adr : props.getProperty("admin").split(";")) { email.addTo(adr); } setEmailProps(email); email.send(); } catch (Exception e) { log.error("{}: {}", e.getClass().getName(), e.getMessage()); throw new Exception("We are unable to send your message right now."); } }
From source file:ch.sdi.core.impl.mail.MailSenderDefaultTest.java
/** * Test method for {@link ch.sdi.core.impl.mail.MailSenderDefault#sendMail(org.apache.commons.mail.Email)}. *///from w ww .ja va2 s . c o m @Ignore("TODO: Provide a mocked mail sink ") @Test public void testSendMail() throws Throwable { Email email = new SimpleEmail(); email.addTo("heri@lamp.vm"); email.setSubject("Testmail"); email.setMsg("Dies ist ein Testmail"); myLog.debug("Test: sending simple mail: " + email); myClassUnderTest.sendMail(email); }
From source file:com.github.triceo.robozonky.notifications.email.AbstractEmailingListener.java
@Override public void handle(final T event) { if (!this.shouldSendEmail(event)) { LOGGER.debug("Will not send e-mail."); return;//from w w w.j av a 2 s. c om } else try { final Email email = AbstractEmailingListener.createNewEmail(properties); email.setSubject(this.getSubject(event)); email.setMsg(TemplateProcessor.INSTANCE.process(this.getTemplateFileName(), this.getData(event))); LOGGER.debug("Will send '{}' from {} to {} through {}:{} as {}.", email.getSubject(), email.getFromAddress(), email.getToAddresses(), email.getHostName(), email.getSmtpPort(), properties.getSmtpUsername()); email.send(); emailsOfThisType.increase(); this.properties.getGlobalCounter().increase(); } catch (final Exception ex) { throw new RuntimeException("Failed processing event.", ex); } }
From source file:com.pax.pay.trans.receipt.paperless.AReceiptEmail.java
public int sendTextEmail(EmailInfo emailInfo, String emailAddress, String subject, String content) { try {/*from ww w .j av a 2 s . co m*/ Email email = new SimpleEmail(); setBaseInfo(emailInfo, email); email.setSubject(subject); email.setMsg(content); email.addTo(emailAddress); email.send(); } catch (EmailException e) { e.printStackTrace(); return -1; } return 0; }
From source file:com.clavain.alerts.Methods.java
private static void sendMail(String title, String message, String emailaddy) { try {/*w w w . j a v a 2 s. c o m*/ Email email = new SimpleEmail(); email.setHostName(p.getProperty("mailserver.host")); email.setSmtpPort(Integer.parseInt(p.getProperty("mailserver.port"))); if (p.getProperty("mailserver.useauth").equals("true")) { email.setAuthentication(p.getProperty("mailserver.user"), p.getProperty("mailserver.pass")); } if (p.getProperty("mailserver.usessl").equals("true")) { email.setSSLOnConnect(true); } else { email.setSSLOnConnect(false); } email.setFrom(p.getProperty("mailserver.from")); email.setSubject("[MuninMX] " + title); email.setMsg(message); email.addTo(emailaddy); email.send(); } catch (Exception ex) { logger.warn("Unable to send Mail: " + ex.getLocalizedMessage()); } }