List of usage examples for org.apache.commons.mail Email setSubject
public Email setSubject(final String aSubject)
From source file:com.mycollab.servlet.EmailValidationServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String smtpUserName = request.getParameter("smtpUserName"); String smtpPassword = request.getParameter("smtpPassword"); String smtpHost = request.getParameter("smtpHost"); String smtpPort = request.getParameter("smtpPort"); String tls = request.getParameter("tls"); String ssl = request.getParameter("ssl"); int mailServerPort = 25; try {//from ww w. j av a 2 s .c om mailServerPort = Integer.parseInt(smtpPort); } catch (Exception e) { LOG.info("The smtp port value is not a number. We will use default port value is 25"); } try { Email email = new SimpleEmail(); email.setHostName(smtpHost); email.setSmtpPort(mailServerPort); email.setAuthenticator(new DefaultAuthenticator(smtpUserName, smtpPassword)); if ("true".equals(tls)) { email.setStartTLSEnabled(true); } else { email.setStartTLSEnabled(false); } if ("true".equals(ssl)) { email.setSSLOnConnect(true); } else { email.setSSLOnConnect(false); } email.setFrom(smtpUserName); email.setSubject("MyCollab Test Email"); email.setMsg("This is a test mail ... :-)"); email.addTo(smtpUserName); email.send(); } catch (EmailException e) { PrintWriter out = response.getWriter(); out.write("Cannot establish SMTP connection. Please recheck your config."); LOG.warn("Can not login to SMTP", e); } }
From source file:FacultyAdvisement.SignupBean.java
public String validateSignUp(ArrayList<Course> list, Appointment appointment) throws SQLException, IOException, EmailException { if (this.desiredCoureses == null || this.desiredCoureses.size() < 1) { FacesContext.getCurrentInstance().addMessage("desiredCourses:Submit", new FacesMessage(FacesMessage.SEVERITY_FATAL, "Please select some courses before confirming an appointment.", null)); }//from w w w . jav a 2 s . c om for (int i = 0; i < list.size(); i++) { if (!this.checkRequsites(CourseRepository.readCourseWithRequisites(ds, list.get(i)))) { return null; } } try { DesiredCourseRepository.deleteFromAppointment(ds, this.appointment.aID); } catch (SQLException ex) { Logger.getLogger(UserBean.class.getName()).log(Level.SEVERE, null, ex); } DesiredCourseRepository.createDesiredCourses(ds, desiredCoureses, Long.toString(appointment.aID)); if (!this.edit) { 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("UCO Faculty Advisement Appointmen Confirmation"); StringBuilder table = new StringBuilder(); table.append("<style>" + "td" + "{border-left:1px solid black;" + "border-top:1px solid black;}" + "table" + "{border-right:1px solid black;" + "border-bottom:1px solid black;}" + "</style>"); table.append( "<table><tr><td width=\"350\">Course Name</td><td width=\"350\">Course Subject</td><td width=\"350\">Course Number</td><td width=\"350\">Course Credits</td></tr> </table>"); for (int i = 0; i < this.desiredCoureses.size(); i++) { table.append("<tr><td width=\"350\">" + this.desiredCoureses.get(i).getName() + "</td>" + "<td width=\"350\">" + this.desiredCoureses.get(i).getSubject() + "</td>" + "<td width=\"350\">" + this.desiredCoureses.get(i).getNumber() + "</td>" + "<td width=\"350\">" + this.desiredCoureses.get(i).getCredits() + "</td></tr>" ); } email.setMsg("<p>Your appointment with your faculty advisor is at " + appointment.datetime + " on " + appointment.date + " . </p>" + "<p align=\"center\">Desired Courses</p>" + table.toString() + "<p align=\"center\">UCO Faculty Advisement</p></font>" ); email.addTo(username); email.send(); } catch (EmailException ex) { Logger.getLogger(VerificationBean.class.getName()).log(Level.SEVERE, null, ex); } } return "/customerFolder/profile.xhtml"; }
From source file:Control.CommonsMail.java
/** * Classe que envia E-amil// w ww .ja va2 s. 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.irurueta.server.commons.email.ApacheMailSender.java
/** * Internal method to send email using Apache Mail. * @param m email message.//from w ww .j a v a 2 s . c om * @param email apache email message. * @throws NotSupportedException if feature is not supported. * @throws EmailException if Apache Mail cannot send email. * @throws com.irurueta.server.commons.email.EmailException if sending * email fails. */ private void internalSendApacheEmail(EmailMessage m, Email email) throws NotSupportedException, EmailException, com.irurueta.server.commons.email.EmailException { email.setHostName(mMailHost); email.setSmtpPort(mMailPort); if (mMailId != null && !mMailId.isEmpty() && mMailPassword != null && !mMailPassword.isEmpty()) { email.setAuthenticator(new DefaultAuthenticator(mMailId, mMailPassword)); } email.setStartTLSEnabled(true); email.setFrom(mMailFromAddress); if (m.getSubject() != null) { email.setSubject(m.getSubject()); } m.buildContent(email); //add destinatoins for (String s : (List<String>) m.getTo()) { email.addTo(s); } for (String s : (List<String>) m.getCC()) { email.addCc(s); } for (String s : (List<String>) m.getBCC()) { email.addBcc(s); } email.send(); }
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) {// w ww . j a v a 2s. c om 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:egovframework.rte.tex.com.service.impl.EgovMailServiceImpl.java
/** * ? ?? ?? ./* w ww.j a v a 2 s . c om*/ * @param vo ? * @return ? */ @Override @SuppressWarnings("deprecation") public boolean sendEmailTo(MemberVO vo) { boolean result = false; Email email = new SimpleEmail(); email.setCharset("utf-8"); // ? // setHostName? ? // email.setHostName(mailInfoService.getString("hostName")); // SpEL? properties ? email.setHostName(hostName); // SMTP email.setSmtpPort(port); email.setAuthenticator(new DefaultAuthenticator(mailId, mailPass)); email.setTLS(true); try { email.addTo(vo.getEmail(), vo.getId()); // ? } catch (EmailException e) { e.printStackTrace(); } try { email.setFrom(mailId, mailName); // } catch (EmailException e) { e.printStackTrace(); } email.setSubject(subject); // ? email.setContent("ID: " + vo.getId() + "<br>" + "PASSWORD: " + vo.getPassword(), "text/plain; charset=utf-8"); try { email.send(); result = true; } catch (EmailException e) { e.printStackTrace(); } return result; }
From source file:au.edu.ausstage.utils.EmailManager.java
/** * A method for sending a simple email message * * @param subject the subject of the message * @param message the text of the message * * @return true, if and only if, the email is successfully sent *//*from w ww . j a va 2s .c o m*/ public boolean sendSimpleMessage(String subject, String message) { // check the input parameters if (InputUtils.isValid(subject) == false || InputUtils.isValid(message) == false) { throw new IllegalArgumentException("The subject and message parameters cannot be null"); } try { // define helper variables Email email = new SimpleEmail(); // configure the instance of the email class email.setSmtpPort(options.getPortAsInt()); // define authentication if required if (InputUtils.isValid(options.getUser()) == true) { email.setAuthenticator(new DefaultAuthenticator(options.getUser(), options.getPassword())); } // turn on / off debugging email.setDebug(DEBUG); // set the host name email.setHostName(options.getHost()); // set the from email address email.setFrom(options.getFromAddress()); // set the subject email.setSubject(subject); // set the message email.setMsg(message); // set the to address String[] addresses = options.getToAddress().split(":"); for (int i = 0; i < addresses.length; i++) { email.addTo(addresses[i]); } // set the security options if (options.getTLS() == true) { email.setTLS(true); } if (options.getSSL() == true) { email.setSSL(true); } // send the email email.send(); } catch (EmailException ex) { if (DEBUG) { System.err.println("ERROR: Sending of email failed.\n" + ex.toString()); } return false; } return true; }
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 w w. j a va 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: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 w w w. jav a2s.co 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(); }
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);// w ww .j a v a 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(); }