List of usage examples for org.apache.commons.mail Email setMsg
public abstract Email setMsg(String msg) throws EmailException;
From source file:com.patrolpro.beans.ContactUsBean.java
public String sendEmail() { try {/*from w w w.j a v a2 s.co m*/ StringBuilder emailMessage = new StringBuilder(); emailMessage.append("From: " + this.name + "\r\n"); emailMessage.append("Email: " + this.email + "\r\n"); emailMessage.append("Phone: " + this.phone + "\r\n"); emailMessage.append(message); Email htmlEmail = new SimpleEmail(); htmlEmail.setMsg(message); htmlEmail.setFrom("contact@patrolpro.com"); htmlEmail.setSubject("Contact Us Email"); htmlEmail.addTo("rharris@ainteractivesolution.com"); htmlEmail.addCc("ijuneau@ainteractivesolution.com"); htmlEmail.addCc("jc@champ.net"); htmlEmail.setMsg(emailMessage.toString()); htmlEmail.setAuthenticator(new MailAuthenticator("schedfox", "Sch3dF0x4m3")); htmlEmail.setHostName("mail2.champ.net"); htmlEmail.setSmtpPort(587); htmlEmail.send(); return "sentContactEmail"; } catch (Exception exe) { } return "invalid"; }
From source file:br.com.utfpr.edu.br.agenda.ServicoMail.EnviaEmailSimpleMail.java
public void envio(String destino) { Email email = new SimpleEmail(); try {//w w w.java2 s . co 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: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.ja v a 2s .co m 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 va2 s.com*/ 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)}. */// w ww . j a v a 2 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.pax.pay.trans.receipt.paperless.AReceiptEmail.java
public int sendTextEmail(EmailInfo emailInfo, String emailAddress, String subject, String content) { try {//from ww w .ja va 2 s . c o 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.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;/*ww w .j a v a 2s. com*/ } 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:ch.sbb.releasetrain.utils.emails.SMTPUtilImpl.java
@Override public void send(String absender, String empfaenger, String betreff, String text) { try {/* w w w . ja v a2s.c o m*/ final Email email = new SimpleEmail(); email.setHostName(mailhost); email.setSmtpPort(mailport); email.setFrom(absender); email.setSubject(betreff); email.setMsg(text); email.addTo(empfaenger); email.send(); log.info("mail sent to: " + empfaenger); } catch (final EmailException e) { log.error(e.getMessage(), e); } }
From source file:com.clavain.alerts.Methods.java
private static void sendMail(String title, String message, String emailaddy) { try {/*from w ww . ja v a 2 s . co 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()); } }
From source file:ch.unibas.fittingwizard.application.tools.Notifications.java
private void sendMailTesting() { try {//www .j a v a 2 s . c o m Email email = new SimpleEmail(); email.setMailSession(Session.getDefaultInstance(props)); email.setSubject("Test mail"); email.setMsg("This is a test mail for checking parameters from config file"); email.setFrom(getSender().trim()); email.addTo(getRecipient().trim()); email.send(); } catch (EmailException e) { throw new RuntimeException("Could not send notification.", e); } }