List of usage examples for org.apache.commons.mail Email setSSL
@Deprecated public void setSSL(final boolean ssl)
From source file:com.aprodher.actions.util.EmailUtils.java
public static Email conectaEmail() throws EmailException { Email email = new SimpleEmail(); email.setHostName(HOSTNAME);// ww w . j a va 2 s .c o m email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator(USERNAME, PASSWORD)); email.setSSL(true); email.setTLS(true); email.setFrom(EMAILORIGEM); return email; }
From source file:de.maklerpoint.office.Schnittstellen.Email.SimpleEmailSender.java
/** * /*from w ww .java2s .c o m*/ * @param adress * @param Subject * @param body * @throws EmailException */ public static void sendSimpleEMail(String adress, String Subject, String body) throws EmailException { Email email = new SimpleEmail(); email.setHostName(Config.get("mailHost", "")); email.setSmtpPort(Config.getConfigInt("emailPort", 25)); email.setTLS(Config.getConfigBoolean("mailTLS", false)); email.setSSL(Config.getConfigBoolean("mailSSL", false)); //email.setSslSmtpPort(Config.getConfigInt("emailPort", 25)); email.setAuthenticator( new DefaultAuthenticator(Config.get("mailUsername", ""), Config.get("mailPassword", ""))); email.setFrom(Config.get("mailSendermail", ""), Config.get("mailSender", "")); email.setSubject(Subject); email.setMsg(body); email.addTo(adress); email.send(); }
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 w w w .j a v a 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: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); //Se true, exibe na saida todo o processo do envio do email email.setDebug(true);// w ww . j av a 2 s.c o m email.send(); }
From source file:com.swissbit.ifttt.IFTTTConfgurationImpl.java
/** {@inheritDoc} */ @Override// www . j av a 2 s . c o m public void trigger() { LOGGER.debug("IFTTT Email is getting sent..."); final List<String> tags = this.retrieveHashtags(this.m_hashTags); if (tags.size() == 0) { return; } if (tags.size() > 0) { for (final String tag : tags) { try { final Email email = new SimpleEmail(); email.setHostName(this.m_smtpHost); email.setSmtpPort(this.m_smtpPort); email.setAuthenticator(new DefaultAuthenticator(this.m_smtpUsername, this.m_smtpPassword)); email.setSSL(true); email.setFrom(this.m_smtpUsername); email.setSubject(tag); email.setMsg("This is a test mail ... :-)"); email.addTo(TRIGGER_EMAIL); email.send(); } catch (final EmailException e) { LOGGER.error(Throwables.getStackTraceAsString(e)); } } } LOGGER.debug("IFTTT Email is sent...Done"); }
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);/*from w ww . j ava 2 s .c om*/ 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:iddb.core.util.MailManager.java
private void setEmailProps(Email email) throws EmailException { email.setFrom(props.getProperty("from"), "IPDB"); if (props.containsKey("bounce")) email.setBounceAddress(props.getProperty("bounce")); if (props.containsKey("host")) email.setHostName(props.getProperty("host")); if (props.containsKey("port")) email.setSmtpPort(Integer.parseInt(props.getProperty("port"))); if (props.containsKey("username")) email.setAuthenticator(//from w w w . ja va 2s . c o m new DefaultAuthenticator(props.getProperty("username"), props.getProperty("password"))); if (props.containsKey("ssl") && props.getProperty("ssl").equalsIgnoreCase("true")) email.setSSL(true); if (props.containsKey("tls") && props.getProperty("tls").equalsIgnoreCase("true")) email.setTLS(true); if (props.containsKey("debug") && props.getProperty("debug").equalsIgnoreCase("true")) email.setDebug(true); }
From source file:com.jnd.sonar.analysisreport.AnalysisReportHelper.java
public void sendNotificationSMS(String send_sms_to_provider, String send_sms_to, String from, String username, String password, String hostname, String portno, boolean setSSLOnConnectFlag, String subject, String message) {/* ww w. j a va 2s. c o m*/ try { send_sms_to_provider = settings.getString(TO_SMS_PROVIDER_PROPERTY); send_sms_to = settings.getString(TO_SMS_PROPERTY); Email smsObject = new SimpleEmail(); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Calendar cal = Calendar.getInstance(); String dateStr = dateFormat.format(cal.getTime()); smsObject.setHostName(hostname); smsObject.setSmtpPort(Integer.parseInt(portno)); smsObject.setAuthenticator(new DefaultAuthenticator(username, password)); smsObject.setSSL(true); smsObject.setFrom(from); smsObject.setSubject(""); smsObject.setMsg("Sonar analysis completed successfully at " + dateStr + " . Please visit " + settings.getString("sonar.host.url") + " for more details!"); //multiple SMS recipients. String[] addrs = StringUtils.split(to_email, "\t\r\n;, "); for (String addr : addrs) { smsObject.addTo(send_sms_to); } smsObject.send(); } catch (EmailException e) { throw new SonarException("Unable to send sms", e); } catch (Exception ex) { // TODO Auto-generated catch block ex.printStackTrace(); } }
From source file:com.ning.billing.util.email.DefaultEmailSender.java
private void sendEmail(final List<String> to, final List<String> cc, final String subject, final Email email) throws EmailApiException { try {/*from www. j a v a2 s .c om*/ email.setSmtpPort(config.getSmtpPort()); if (config.useSmtpAuth()) { email.setAuthentication(config.getSmtpUserName(), config.getSmtpPassword()); } email.setHostName(config.getSmtpServerName()); email.setFrom(config.getDefaultFrom()); email.setSubject(subject); if (to != null) { for (final String recipient : to) { email.addTo(recipient); } } if (cc != null) { for (final String recipient : cc) { email.addCc(recipient); } } email.setSSL(config.useSSL()); log.info("Sending email to {}, cc {}, subject {}", new Object[] { to, cc, subject }); email.send(); } catch (EmailException ee) { throw new EmailApiException(ee, ErrorCode.EMAIL_SENDING_FAILED); } }
From source file:com.googlecode.fascinator.messaging.EmailNotificationConsumer.java
private void sendEmails(List<String> toList, List<String> ccList, String subject, String body, String fromAddress, String fromName, boolean isHtml) throws EmailException { Email email = null; if (isHtml) { email = new HtmlEmail(); ((HtmlEmail) email).setHtmlMsg(body); } else {/*from ww w. jav a2 s. c o m*/ email = new SimpleEmail(); email.setMsg(body); } email.setDebug(debug); email.setHostName(smtpHost); if (smtpUsername != null || smtpPassword != null) { email.setAuthentication(smtpUsername, smtpPassword); } email.setSmtpPort(smtpPort); email.setSslSmtpPort(smtpSslPort); email.setSSL(smtpSsl); email.setTLS(smtpTls); email.setSubject(subject); for (String to : toList) { email.addTo(to); } if (ccList != null) { for (String cc : ccList) { email.addCc(cc); } } email.setFrom(fromAddress, fromName); email.send(); }