List of usage examples for org.apache.commons.mail Email setMsg
public abstract Email setMsg(String msg) throws EmailException;
From source file:ch.unibas.fittingwizard.application.tools.Notifications.java
private void sendErrorLogByMail() { try {/*from ww w .j a va2 s . c o m*/ Email email = new SimpleEmail(); email.setMailSession(Session.getDefaultInstance(props)); email.setSubject("Log of FW session"); email.setMsg(new String(Files.readAllBytes(Paths.get("fw-log.txt")))); email.setFrom(getSender().trim()); email.addTo(getRecipient().trim()); email.send(); } catch (IOException | EmailException e) { throw new RuntimeException("Could not send notification.", e); } }
From source file:ch.unibas.fittingwizard.application.tools.Notifications.java
private void sendMailGaussian(boolean isLogValid) { try {/*from ww w .j a va 2 s .com*/ Email email = new SimpleEmail(); email.setMailSession(Session.getDefaultInstance(props)); email.setSubject("Gaussian calculation finished"); email.setMsg("Gaussian calculation finished. Log file validation returned: " + isLogValid); email.setFrom(getSender().trim()); email.addTo(getRecipient().trim()); email.send(); } catch (EmailException e) { throw new RuntimeException("Could not send notification.", e); } }
From source file:br.com.recursive.biblioteca.servicos.EmailService.java
public void sendHtmlEmail(Pessoa pessoa) throws EmailException { Email email = new HtmlEmail(); email.setAuthenticator(new DefaultAuthenticator("claupwd@gmail.com", "@claupwd2014")); email.setHostName("smtp.gmail.com"); email.setFrom("claupwd@gmail.com"); email.setSubject("SIB Online - Recuperao de Senha"); email.setMsg(createMessage(pessoa)); email.addTo(pessoa.getContato().getEmail()); email.setSSL(true);/*from ww w. j a v a 2 s. co m*/ //Se true, exibe na saida todo o processo do envio do email email.setDebug(true); email.send(); }
From source file:com.packtpub.e4.advanced.event.mailman.MailSender.java
@Override public void handleEvent(Event event) { String topic = event.getTopic(); if (topic.startsWith("smtp/")) { String importance = topic.substring("smtp/".length()); String to = (String) event.getProperty("To"); String from = (String) event.getProperty("From"); String subject = (String) event.getProperty("Subject"); String body = (String) event.getProperty("DATA"); try {/* w w w. ja va 2s .c o m*/ Email email = new SimpleEmail(); email.setDebug(false); email.setHostName(hostname); email.setSmtpPort(port); email.setFrom(from); email.addTo(to); email.setSubject(subject); email.setMsg(body); email.addHeader("Importance", importance); email.send(); log(LogService.LOG_INFO, "Message sent successfully to " + to); } catch (EmailException e) { log(LogService.LOG_ERROR, "Error occurred" + e); } } }
From source file:br.com.jvmsoftware.util.EnviarMail.java
public void emailSimples(PubConfigEmpresa conf, PubUsuario usu, String msg, String subj) throws EmailException { Email email = new SimpleEmail(); email.setHostName(conf.getMailEnvioSmtp()); email.setSmtpPort(conf.getMailEnvioPorta()); email.setAuthenticator(new DefaultAuthenticator(conf.getMailEnvio(), conf.getMailEnvioSenha())); email.setSSLOnConnect(true);/*from ww w .jav a2s . c om*/ email.setFrom(conf.getMailEnvio()); email.setSubject(subj); email.setMsg(msg); email.addTo(usu.getEmail()); email.send(); }
From source file:com.intuit.wasabi.email.impl.EmailServiceImpl.java
void send(String subject, String msg, String... to) { String[] clearTo = removeInvalidEmails(to); if (isActive()) { try {// ww w . j av a2s. com Email email = createSimpleMailService(); email.setHostName(host); email.setFrom(from); email.setSubject(subjectPrefix + " " + subject); email.setMsg(msg); email.addTo(clearTo); email.send(); } catch (EmailException mailExcp) { LOGGER.error("Email could not be send because of " + mailExcp.getMessage()); throw new WasabiEmailException("Email: " + emailToString(subject, msg, to) + " could not be sent.", mailExcp); } } else { //if the service is not active log the email that would have been send and throw error LOGGER.info("EmailService would have sent: " + emailToString(subject, msg, to)); throw new WasabiEmailException(ErrorCode.EMAIL_NOT_ACTIVE_ERROR, "The EmailService is not active."); } }
From source file:com.cognifide.qa.bb.email.EmailSender.java
public void sendEmail(final EmailData emailData) { try {/*from w w w .ja v a 2 s .c om*/ Email email = new SimpleEmail(); email.setHostName(smtpServer); email.setSmtpPort(smtpPort); email.setAuthenticator(new DefaultAuthenticator(username, password)); email.setSSLOnConnect(secure); email.setFrom(emailData.getAddressFrom()); email.setSubject(emailData.getSubject()); email.setMsg(emailData.getMessageContent()); email.addTo(emailData.getAddressTo()); email.send(); } catch (org.apache.commons.mail.EmailException e) { throw new EmailException(e); } }
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); email.send();// w ww. j a v a 2s.co m }
From source file:com.pronoiahealth.olhie.server.services.MailSendingService.java
/** * Author Request email that goes to the olhie administrator * //from www. j a va 2 s . c o m * @param toEmail * @param userId * @param firstName * @param lastName * @param regId * @throws Exception */ public void sendRequestAuthorMailFromApp(String toEmail, String userId, String firstName, String lastName, String regId) throws Exception { Email email = new SimpleEmail(); email.setSmtpPort(Integer.parseInt(smtpPort)); email.setAuthenticator(new DefaultAuthenticator(fromAddress, fromPwd)); email.setDebug(Boolean.parseBoolean(debugEnabled)); email.setHostName(smtpSever); email.setFrom(fromAddress); email.setSubject("Author Request"); email.setMsg("User Id: " + userId + " Name: " + firstName + " " + lastName + " Registration Id: " + regId); email.addTo(toEmail); email.setTLS(Boolean.parseBoolean(tlsEnabled)); email.setSocketTimeout(10000); email.setSocketConnectionTimeout(12000); email.send(); }
From source file:com.pronoiahealth.olhie.server.services.MailSendingService.java
/** * Sends a password reset email to the email address provided * /*from www .j a v a 2 s .c o m*/ * @param toEmail * @param newPwd * @throws Exception */ public void sendPwdResetMailFromApp(String toEmail, String newPwd) throws Exception { Email email = new SimpleEmail(); email.setSmtpPort(Integer.parseInt(smtpPort)); email.setAuthenticator(new DefaultAuthenticator(fromAddress, fromPwd)); email.setDebug(Boolean.parseBoolean(debugEnabled)); email.setHostName(smtpSever); email.setFrom(fromAddress); email.setSubject("Reset Olhie Password"); email.setMsg("You have requested that your password be reset. Your new Olhie password is " + newPwd); email.addTo(toEmail); email.setTLS(Boolean.parseBoolean(tlsEnabled)); email.setSocketTimeout(10000); email.setSocketConnectionTimeout(12000); email.send(); }