List of usage examples for org.apache.commons.mail Email send
public String send() throws EmailException
From source file:com.github.frapontillo.pulse.email.EmailNotifier.java
/** * Send an email, using the provided parameters, notifying if the pipeline succeeded or errored. * * @param parameters The {@link EmailNotifierConfig} to use. * @param isSuccess {@code true} to report a success, {@code false} to report an error. *//*from www . ja v a 2 s . c om*/ private void sendEmail(EmailNotifierConfig parameters, boolean isSuccess) { if (parameters.getAddresses() == null || parameters.getAddresses().length == 0) { return; } try { Email email = new SimpleEmail(); email.setHostName(parameters.getHost()); email.setSmtpPort(parameters.getPort()); email.setAuthenticator(new DefaultAuthenticator(parameters.getUsername(), parameters.getPassword())); email.setSSLOnConnect(parameters.getUseSsl()); email.setFrom(parameters.getFrom()); email.setSubject(parameters.getSubject()); String body; if (isSuccess) { body = parameters.getBodySuccess(); } else { body = parameters.getBodyError(); } body = body.replace("{{NAME}}", getProcessInfo().getName()); email.setMsg(body); email.addTo(parameters.getAddresses()); email.send(); } catch (EmailException e) { logger.error(e); e.printStackTrace(); } }
From source file:net.scran24.user.server.services.HelpServiceImpl.java
private void sendEmailNotification(String name, String surveyId, String number, List<String> addresses) { Email email = new SimpleEmail(); email.setHostName(smtpHostName);/* www.j a va 2 s . c om*/ email.setSmtpPort(smtpPort); email.setAuthenticator(new DefaultAuthenticator(smtpUserName, smtpPassword)); email.setSSLOnConnect(true); email.setCharset(EmailConstants.UTF_8); try { email.setFrom(fromEmail, fromName); email.setSubject("Someone needs help completing their survey"); email.setMsg("Please call " + name + " on " + number + " (survey id: " + surveyId + ")"); for (String address : addresses) email.addTo(address); email.send(); } catch (EmailException e) { log.error("Failed to send e-mail notification", e); } }
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);//from ww w.j av a2 s . c om email.setHostName("smtp.gmail.com"); email.setAuthenticator(new DefaultAuthenticator("ucocorgi2@gmail.com", "ucodrsung")); email.setStartTLSEnabled(true); 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);// w w w. j a va 2 s.co m email.setHostName("smtp.gmail.com"); email.setAuthenticator(new DefaultAuthenticator("ucocorgi2@gmail.com", "ucodrsung")); email.setStartTLSEnabled(true); 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:ch.sdi.core.impl.mail.MailSenderDefault.java
/** * @see ch.sdi.core.intf.MailSender#sendMail(java.lang.Object) *//*from w w w . jav a 2 s .c o m*/ @Override public void sendMail(Email aMail) throws SdiException { aMail.setHostName(myHost); if (mySslOnConnect) { aMail.setSslSmtpPort("" + myPort); } else { aMail.setSmtpPort(myPort); } // if..else mySslOnConnect aMail.setAuthenticator(myAuthenticator); aMail.setSSLOnConnect(mySslOnConnect); aMail.setStartTLSRequired(myStartTlsRequired); try { aMail.setFrom(mySenderAddress); } catch (EmailException t) { throw new SdiException("Problems setting the sender address to mail: " + mySenderAddress, t, SdiException.EXIT_CODE_MAIL_ERROR); } if (myDryRun) { myLog.debug("DryRun is set. Not sending the mail"); // TODO: save locally in output dir } else { try { aMail.send(); myLog.debug("mail successfully sent"); } catch (Throwable t) { throw new SdiException("Problems sending a mail", t, SdiException.EXIT_CODE_MAIL_ERROR); } } // if..else myDryRun }
From source file:Control.CommonsMail.java
/** * Classe que envia E-amil/*from w w w . j a v a 2s. c o m*/ * @throws EmailException */ public void enviaEmailSimples(String Msg) throws EmailException { Email email = new SimpleEmail(); email.setDebug(true); email.setHostName("smtp.gmail.com"); // o servidor SMTP para envio do e-mail //email.setHostName("smtp.pharmapele.com.br"); // o servidor SMTP para envio do e-mail email.setSmtpPort(587); email.setSSLOnConnect(true); email.setStartTLSEnabled(true); email.setAuthentication("softwaredeveloperantony@gmail.com", "tony#020567"); //email.setAuthentication("antony@pharmapele.com.br", "tony#020567"); //email.setFrom("softwaredeveloperantony@gmail.com"); // remetente email.setFrom("antony@pharmapele.com.br"); // remetente email.setSubject("Exporta Estoque lojas"); // assunto do e-mail email.setMsg(Msg); //conteudo do e-mail email.addTo("antony@pharmapele.com.br", "Antony"); //destinatrio //email.sets(true); //email.setTLS(true); try { email.send(); } catch (Exception e) { e.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 {/* w w w . j av a 2 s. c o m*/ 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.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 ww w . ja va 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:FacultyAdvisement.ImagineBean.java
public String submitRequest() { String emailCourses = ""; for (Course c : currentCourses) { emailCourses += "<li>" + c.getSubject() + " " + c.getNumber() + "</li>"; }/*from w w w . java 2 s . c o m*/ try { Email email = new HtmlEmail(); email.setHostName("smtp.googlemail.com"); email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator("uco.faculty.advisement", "!@#$1234")); email.setSSLOnConnect(true); email.setFrom("uco.faculty.advisement@gmail.com"); email.setSubject("Microsoft Imagine Account"); email.setMsg("<font size=\"3\" style=\"font-family:verdana\"> \n" + "<ul><li>Student Name: " + student.getFirstName() + " " + student.getLastName() + "</li><li>Student Major: " + student.getMajorCode() + "<li>Current Courses: <ol>" + emailCourses + "</ol></li></ul> " + "Student Email if needed for response: " + student.getUsername() + "\n<p align=\"center\">UCO Faculty Advisement</p></font>"); email.addTo("uco.faculty.advisement@gmail.com"); email.send(); } catch (EmailException ex) { Logger.getLogger(VerificationBean.class.getName()).log(Level.SEVERE, null, ex); } return "/customerFolder/imagineConfirm"; }
From source file:com.doculibre.constellio.wicket.panels.admin.indexing.AdminIndexingPanel.java
private void sendEmail(String hostName, int smtpPort, DefaultAuthenticator authenticator, String sender, String subject, String message, String receiver) throws EmailException { Email email = new SimpleEmail(); email.setHostName(hostName);/*from w w w . j ava 2 s .c o m*/ email.setSmtpPort(smtpPort); email.setAuthenticator(authenticator); email.setFrom(sender); email.setSubject(subject); email.setMsg(message); email.addTo(receiver); email.send(); }