List of usage examples for org.apache.commons.mail Email setDebug
public void setDebug(final boolean d)
From source file:com.mirth.connect.connectors.smtp.SmtpSenderService.java
@Override public Object invoke(String channelId, String method, Object object, String sessionId) throws Exception { if (method.equals("sendTestEmail")) { SmtpDispatcherProperties props = (SmtpDispatcherProperties) object; String host = replacer.replaceValues(props.getSmtpHost(), channelId); String portString = replacer.replaceValues(props.getSmtpPort(), channelId); int port = -1; try {/*from ww w . j ava 2 s .co m*/ port = Integer.parseInt(portString); } catch (NumberFormatException e) { return new ConnectionTestResponse(ConnectionTestResponse.Type.FAILURE, "Invalid port: \"" + portString + "\""); } String secure = props.getEncryption(); boolean authentication = props.isAuthentication(); String username = replacer.replaceValues(props.getUsername(), channelId); String password = replacer.replaceValues(props.getPassword(), channelId); String to = replacer.replaceValues(props.getTo(), channelId); String from = replacer.replaceValues(props.getFrom(), channelId); Email email = new SimpleEmail(); email.setDebug(true); email.setHostName(host); email.setSmtpPort(port); if ("SSL".equalsIgnoreCase(secure)) { email.setSSL(true); } else if ("TLS".equalsIgnoreCase(secure)) { email.setTLS(true); } if (authentication) { email.setAuthentication(username, password); } email.setSubject("Mirth Connect Test Email"); try { for (String toAddress : StringUtils.split(to, ",")) { email.addTo(toAddress); } email.setFrom(from); email.setMsg( "Receipt of this email confirms that mail originating from this Mirth Connect Server is capable of reaching its intended destination.\n\nSMTP Configuration:\n- Host: " + host + "\n- Port: " + port); email.send(); return new ConnectionTestResponse(ConnectionTestResponse.Type.SUCCESS, "Sucessfully sent test email to: " + to); } catch (EmailException e) { return new ConnectionTestResponse(ConnectionTestResponse.Type.FAILURE, e.getMessage()); } } return null; }
From source file:edu.corgi.uco.sendEmails.java
public void sendConfirmation(String email2, String firstName, String lastName, int token, int id) throws EmailException { Email email = new SimpleEmail(); email.setDebug(true); email.setHostName("smtp.gmail.com"); email.setAuthenticator(new DefaultAuthenticator("ucocorgi2@gmail.com", "ucodrsung")); email.setStartTLSEnabled(true);//w w w . jav a 2 s . c o m email.setSmtpPort(587); email.setFrom("ucocorgi@gmail.com", "UCO CS Corgi"); email.setSubject("Account Confirmation"); email.setMsg(firstName + " " + lastName + " please go to the following address http://localhost:8080/Corgi/faces/accountAuth.xhtml " + "and enter the token:" + token + " and the ID:" + id + " to confirm and activate your account"); System.out.print("Email Address: " + email2); email.addTo(email2); email.send(); }
From source file:edu.corgi.uco.sendEmails.java
public String send(String emailAddress, String studentFirstName, String studentLastName) throws EmailException { System.out.print("hit send"); Email email = new SimpleEmail(); System.out.print("created email file"); email.setDebug(true); email.setHostName("smtp.gmail.com"); email.setAuthenticator(new DefaultAuthenticator("ucocorgi2@gmail.com", "ucodrsung")); email.setStartTLSEnabled(true);//from w w w . j a v a2s .c o m email.setSmtpPort(587); email.setFrom("ucocorgi@gmail.com", "UCO CS Secretary"); email.setSubject("Advisement Update"); email.setMsg(studentFirstName + " " + studentLastName + " your advisment has been processed and the hold on your account will be removed shortly"); System.out.print("Email Address: " + emailAddress); email.addTo(emailAddress); System.out.print("added values"); email.send(); System.out.print("sent"); return null; }
From source file:com.pronoiahealth.olhie.server.services.MailSendingService.java
/** * Sends a password reset email to the email address provided * // ww w.j a va2s. c om * @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(); }
From source file:com.pronoiahealth.olhie.server.services.MailSendingService.java
/** * Author Request email that goes to the olhie administrator * // www.ja v a 2 s. c om * @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
/** * @param toEmail//from w ww .jav a 2s . com * @param userId * @param firstName * @param lastName * @param eventId * @param details * @throws Exception */ public void sendRequestMailForCalendarEventFromApp(String toEmail, String userId, String firstName, String lastName, String eventId, String details) 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("Calendar Event Request"); email.setMsg("User Id: " + userId + " Name: " + firstName + " " + lastName + " Event Id: " + eventId + "\n" + details); email.addTo(toEmail); email.setTLS(Boolean.parseBoolean(tlsEnabled)); email.setSocketTimeout(10000); email.setSocketConnectionTimeout(12000); email.send(); }
From source file:com.mirth.connect.server.util.SMTPConnection.java
public void send(String toList, String ccList, String from, String subject, String body) throws EmailException { Email email = new SimpleEmail(); email.setHostName(host);/* w ww. j av a 2 s.co m*/ email.setSmtpPort(Integer.parseInt(port)); email.setSocketConnectionTimeout(socketTimeout); email.setDebug(true); if (useAuthentication) { email.setAuthentication(username, password); } if (StringUtils.equalsIgnoreCase(secure, "TLS")) { email.setTLS(true); } else if (StringUtils.equalsIgnoreCase(secure, "SSL")) { email.setSSL(true); } for (String to : StringUtils.split(toList, ",")) { email.addTo(to); } if (StringUtils.isNotEmpty(ccList)) { for (String cc : StringUtils.split(ccList, ",")) { email.addCc(cc); } } email.setFrom(from); email.setSubject(subject); email.setMsg(body); email.send(); }
From source file:edu.br.tcc.ManagedBean.TrabalhosBean.java
public Formulario enviarEmail(Formulario trabalho) { System.out.println("entrou no metodo do mb enviarEmail"); try {/* w ww. j a v a 2 s. c o m*/ System.out.println("teste: " + trabalho.getEmail()); Email emailSimples = new SimpleEmail(); emailSimples.setHostName("smtp.live.com"); emailSimples.setStartTLSEnabled(true); emailSimples.setSmtpPort(587); emailSimples.setDebug(true); emailSimples.setAuthenticator(new DefaultAuthenticator("Seu email outlook", "sua senha")); emailSimples.setFrom("Seu email outlook"); emailSimples.setSubject(formulario.getAssunto()); emailSimples.setMsg(formulario.getTexto() + " " + caminho2 + trabalho.getMatricula() + ".docx"); emailSimples.addTo(trabalho.getEmail()); emailSimples.send(); } catch (EmailException ex) { // System.out.println(""+ex); Logger.getLogger(FormularioDAO.class.getName()).log(Level.SEVERE, null, ex); } return null; }
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 w w w . j a v a 2s. co m //Se true, exibe na saida todo o processo do envio do email email.setDebug(true); email.send(); }
From source file:com.mirth.connect.server.util.ServerSMTPConnection.java
public void send(String toList, String ccList, String from, String subject, String body, String charset) throws EmailException { Email email = new SimpleEmail(); // Set the charset if it was specified. Otherwise use the system's default. if (StringUtils.isNotBlank(charset)) { email.setCharset(charset);//from w ww . ja v a 2 s .com } email.setHostName(host); email.setSmtpPort(Integer.parseInt(port)); email.setSocketConnectionTimeout(socketTimeout); email.setDebug(true); if (useAuthentication) { email.setAuthentication(username, password); } if (StringUtils.equalsIgnoreCase(secure, "TLS")) { email.setStartTLSEnabled(true); } else if (StringUtils.equalsIgnoreCase(secure, "SSL")) { email.setSSLOnConnect(true); email.setSslSmtpPort(port); } // These have to be set after the authenticator, so that a new mail session isn't created ConfigurationController configurationController = ControllerFactory.getFactory() .createConfigurationController(); email.getMailSession().getProperties().setProperty("mail.smtp.ssl.protocols", StringUtils.join( MirthSSLUtil.getEnabledHttpsProtocols(configurationController.getHttpsClientProtocols()), ' ')); email.getMailSession().getProperties().setProperty("mail.smtp.ssl.ciphersuites", StringUtils.join( MirthSSLUtil.getEnabledHttpsCipherSuites(configurationController.getHttpsCipherSuites()), ' ')); for (String to : StringUtils.split(toList, ",")) { email.addTo(to); } if (StringUtils.isNotEmpty(ccList)) { for (String cc : StringUtils.split(ccList, ",")) { email.addCc(cc); } } email.setFrom(from); email.setSubject(subject); email.setMsg(body); email.send(); }