List of usage examples for org.apache.commons.mail Email setMsg
public abstract Email setMsg(String msg) throws EmailException;
From source file:edu.corgi.uco.sendEmails.java
public static void sendAdvisorCancel(String emailAddress, String studentFirstName, String studentLastName) { try {/*from w w w. j a va2s.co m*/ 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); email.setSmtpPort(587); email.setFrom("ucocorgi@gmail.com", "UCO CS Corgi"); email.setSubject("Advisement Update"); email.setMsg( studentFirstName + " " + studentLastName + "your appointment has been canceled by the advisor." + "You will need to log in to CORGI and sign up for another appointment to get advised." + "Thank you."); System.out.print("Email Address: " + emailAddress); email.addTo(emailAddress); System.out.print("added values"); email.send(); System.out.print("sent"); } catch (EmailException ex) { Logger.getLogger(sendEmails.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:edu.corgi.uco.sendEmails.java
public static void sendStudentSignUp(String studentFirstName, String studentLastName, Date time) { try {/* ww w .j a v a 2s. co m*/ 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); email.setSmtpPort(587); email.setFrom("ucocorgi@gmail.com", "UCO Advisement"); email.setSubject("Advisement Update"); email.setMsg("You have a new appointment with " + studentFirstName + " " + studentLastName + " on " + time + ". Any previously " + "scheduled appointments with them have been canceled."); System.out.print("Email Address: ucocorgi@gmail.com"); email.addTo("ucocorgi@gmail.com"); System.out.print("added values"); email.send(); System.out.print("sent"); } catch (EmailException ex) { Logger.getLogger(sendEmails.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:edu.corgi.uco.sendEmails.java
public static void sendStudentConfirmation(String fn, String ln, Date date, String email2) { try {//from w w w.java 2 s .c o m 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); email.setSmtpPort(587); email.setFrom("ucocorgi@gmail.com", "UCO Advisement"); email.setSubject("Advisement Update"); email.setMsg(fn + " " + ln + ", you have signed up for an advisement appointment at " + date + ". It is recommended that you use the Corgi system to define your " + "preferred schedule for next semester prior to your meeting."); System.out.print("Email Address: ucocorgi@gmail.com"); email.addTo(email2); System.out.print("added values"); email.send(); System.out.print("sent"); } catch (EmailException ex) { Logger.getLogger(sendEmails.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:de.maklerpoint.office.Schnittstellen.Email.SimpleEmailSender.java
/** * //from w w w. j ava2s.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.esofthead.mycollab.servlet.InstallUtils.java
public static void checkSMTPConfig(String host, int port, String username, String password, boolean auth, boolean isStartTls, boolean isSSL) { try {//from w ww. j a v a 2 s . c o m Properties props = new Properties(); if (auth) { props.setProperty("mail.smtp.auth", "true"); } else { props.setProperty("mail.smtp.auth", "false"); } if (isStartTls) { props.setProperty("mail.smtp.starttls.enable", "true"); props.setProperty("mail.smtp.startssl.enable", "true"); } else if (isSSL) { props.setProperty("mail.smtp.startssl.enable", "false"); props.setProperty("mail.smtp.ssl.enable", "true"); props.setProperty("mail.smtp.ssl.socketFactory.fallback", "false"); } Email email = new SimpleEmail(); email.setHostName(host); email.setSmtpPort(port); email.setAuthenticator(new DefaultAuthenticator(username, password)); if (isStartTls) { email.setStartTLSEnabled(true); } else { email.setStartTLSEnabled(false); } if (isSSL) { email.setSSLOnConnect(true); } else { email.setSSLOnConnect(false); } email.setFrom(username); email.setSubject("MyCollab Test Email"); email.setMsg("This is a test mail ... :-)"); email.addTo(username); email.send(); } catch (Exception e) { throw new UserInvalidInputException(e); } }
From source file:at.treedb.util.Mail.java
public static void sendMail(String smtpHost, int smtpPort, TransportSecurity transportSecurity, String smtpUser, String smtpPassword, String mailTo, String mailFrom, String subject, String message) throws Exception { Objects.requireNonNull(mailTo, "Mail.sendMail(): mailTo can not be null!"); Objects.requireNonNull(subject, "Mail.sendMail(): subject can not be null!"); Objects.requireNonNull(message, "Mail.sendMail(): message can not be null!"); Email email = new SimpleEmail(); email.setHostName(smtpHost);//from w w w . j a va 2s. c o m email.setAuthenticator(new DefaultAuthenticator(smtpUser, smtpPassword)); if (transportSecurity == TransportSecurity.SSL) { email.setSSLOnConnect(true); email.setSSLCheckServerIdentity(false); } else if (transportSecurity == TransportSecurity.STARTTLS) { email.setStartTLSRequired(true); } email.setSmtpPort(smtpPort); if (mailFrom != null && !mailFrom.isEmpty()) { email.setFrom(smtpUser); } email.setSubject(subject); email.setMsg(message); email.addTo(mailTo); email.send(); }
From source file:AccessControl.java
/** * Send email message for external notifications * * @param subject Email Subject Text// w w w . j av a2 s.c om * @param message Email Message Text */ private static void sendEmail(String subject, String message) { try { if (EMAIL_ENABLED && EMAIL_FROM != null && !EMAIL_FROM.isEmpty()) { Email email = new SimpleEmail(); email.setHostName(EMAIL_SERVER); email.setSmtpPort(EMAIL_PORT); email.setFrom(EMAIL_FROM); email.addTo(EMAIL_TO); email.setSubject(subject); email.setMsg(message); email.send(); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:FacultyAdvisement.StudentRepository.java
public static void adminUpdate(DataSource ds, Student student, String oldUsername) throws SQLException { Connection conn = ds.getConnection(); if (conn == null) { throw new SQLException("conn is null; Can't get db connection"); }// w w w . j a v a 2s.c o m try { PreparedStatement ps; ps = conn.prepareStatement( "Update STUDENT set EMAIL=?, FIRSTNAME=?, LASTNAME=?, MAJORCODE=?, PHONE=?, ADVISED=? where STUID=?"); ps.setString(1, student.getUsername()); ps.setString(2, student.getFirstName()); ps.setString(3, student.getLastName()); ps.setString(4, student.getMajorCode()); ps.setString(5, student.getPhoneNumber()); if (student.isAdvised()) { ps.setString(6, "true"); } else { ps.setString(6, "false"); } ps.setString(7, student.getId()); ps.executeUpdate(); ps = conn.prepareStatement("Update USERTABLE set USERNAME=? where USERNAME=?"); ps.setString(1, student.getUsername()); ps.setString(2, oldUsername); ps.executeUpdate(); ps = conn.prepareStatement("Update GROUPTABLE set USERNAME=? where USERNAME=?"); ps.setString(1, student.getUsername()); ps.setString(2, oldUsername); ps.executeUpdate(); if (student.isResetPassword()) { String newPassword = UUID.randomUUID().toString(); String encryptedPassword = SHA256Encrypt.encrypt(newPassword); ps = conn.prepareStatement("Update USERTABLE set PASSWORD=? where USERNAME=?"); ps.setString(1, encryptedPassword); ps.setString(2, student.getUsername()); ps.executeUpdate(); 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 Password Change"); email.setMsg("<font size=\"3\">An admin has resetted your password, your new password is \"" + newPassword + "\"." + "\n<p align=\"center\">UCO Faculty Advisement</p></font>"); email.addTo(student.getUsername()); email.send(); } } catch (EmailException ex) { Logger.getLogger(StudentRepository.class.getName()).log(Level.SEVERE, null, ex); } finally { conn.close(); } //students = (HashMap<String, StudentPOJO>) readAll(); // reload the updated info }
From source file:ar.com.pahema.utils.MailSender.java
public static void enviar(String destino, Paquete paquete) throws EmailException { try {//from w w w .j ava 2s .c o m Email mail = new SimpleEmail(); //Configuracion necesaria para GMAIL mail.setHostName("mail.pahema.com.ar"); //mail.setTLS(true); mail.setSmtpPort(25); //mail.setSSL(true); //En esta seccion colocar cuenta de usuario de Gmail y contrasea mail.setAuthentication("dante@pahema.com.ar", "Fuerza2015"); //Cuenta de Email Destino // AC? IRIA LA DE ADMINISTRACION DE PAHEMA. mail.addTo("dante.gs@hotmail.com"); mail.addTo(destino); //Cuenta de Email Origen, la misma con la que nos autenticamos mail.setFrom("dante@pahema.com.ar", "Pahema - Sistema Tango"); //Titulo del Email mail.setSubject("Aviso de finalizacin de paquete de horas."); //Contenido del Email mail.setMsg("Estimado cliente,\n" + "Le informamos que su paquete de " + (int) paquete.getCantidadHoras() + " horas est por finalizar.\n" + "Le quedan por usar: " + (int) paquete.getHorasRestantes() + " horas.\n" + "Por favor comunquese con Pahema para el detalle de sus consumos: 4952 - 4789.\n" + "Muchas gracias.\n" + "Administracin."); mail.send(); } catch (EmailException e) { System.out.println(e.getMessage()); throw new RuntimeException("Ocurrio un error en el envio del mail"); } }
From source file:controller.SendMailMachine.java
public static void sendMail(Cart cart, String recipientEmail) { Email email = new SimpleEmail(); email.setHostName(HOST_NAME);/* w w w . j a va 2 s. c o m*/ email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(EMAIL_SENDER, PASSWORD)); email.setSSLOnConnect(true); String subject = "Thng tin ha n"; String content = "\t\t\tTRUNG TM MUA SM BITTORRENT\n\nChi tit n hng ca bn: \n"; for (Map.Entry<Integer, Item> entrySet : cart.getCartItem().entrySet()) { Item item = entrySet.getValue(); content += item.getWatch().getName() + "\t\t\t\t\t\t" + item.getQuantity() + " x " + ((int) item.getWatch().getPrice()) + "000 VND\n"; } content += "Tng ha n: " + ((int) cart.sumPrice()) + "000 VND"; try { email.setFrom(EMAIL_SENDER); email.setCharset("UTF-8"); email.setSubject(subject); email.setMsg(content); email.addTo(recipientEmail); email.send(); } catch (EmailException ex) { ex.printStackTrace(); } }