List of usage examples for org.apache.commons.mail Email setAuthenticator
public void setAuthenticator(final Authenticator newAuthenticator)
Authenticator
to be used when authentication is requested from the mail server. From source file:com.aprodher.actions.util.EmailUtils.java
public static Email conectaEmail() throws EmailException { Email email = new SimpleEmail(); email.setHostName(HOSTNAME);//from w ww .jav a 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:io.jhonesdeveloper.swing.util.EmailUtil.java
public static void sendBasicText(String hostName, String username, String password, String from, String subject, String msg, String[] to) throws EmailException { Email email = new SimpleEmail(); email.setHostName(hostName);// w ww . j a v a 2 s.c o m email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator(username, password)); email.setSSLOnConnect(true); email.setFrom(from); email.setSubject(subject); email.setMsg(msg); email.addTo(to); email.send(); }
From source file:connection.EmailSending.java
public static void sendTextEmail(String subject, String content, String recipientEmail) { Email email = new SimpleEmail(); email.setHostName(MailInfor.HOST_NAME); email.setSmtpPort(465);/*from www. java 2s . c om*/ email.setAuthenticator(new DefaultAuthenticator(MailInfor.EMAIL_SENDER, MailInfor.PASSWORD)); email.setSSLOnConnect(true); try { email.setFrom(MailInfor.EMAIL_SENDER); email.setSubject(subject); email.setMsg(content); email.addTo(recipientEmail); email.send(); } catch (EmailException ex) { Logger.getLogger(EmailSending.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:controller.SendMailMachine.java
public static void sendMail(Cart cart, String recipientEmail) { Email email = new SimpleEmail(); email.setHostName(HOST_NAME);/*from w w w.java 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(); } }
From source file:at.tugraz.kmi.medokyservice.ErrorLogNotifier.java
public static void errorEmail(String msg) { Email email = new SimpleEmail(); email.setHostName("something.com"); email.setSmtpPort(465);/*from w w w . ja va 2 s . c o m*/ DefaultAuthenticator auth = new DefaultAuthenticator("username", "pwd"); email.setAuthenticator(auth); email.setSSLOnConnect(true); try { email.setFrom("email address"); email.setSubject("[MEDoKyService] Error"); email.setMsg(msg); email.addTo("yourmail.com"); email.send(); } catch (EmailException e) { e.printStackTrace(); } }
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 {/*www . j av a2s . co 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);// ww w . ja v a 2 s. 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:edu.corgi.uco.sendEmails.java
public static void sendStudentSignUp(String studentFirstName, String studentLastName, Date time) { try {/*from w w w . jav a 2 s.c om*/ 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 sendSecretaryNotification(String name) { try {/*www . j a v a 2s.com*/ 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"); email.setMsg(name + "'s Schedule has been approved. " + "Please remove their hold promptly so they may enroll."); 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 sendAdvisorCancel(String emailAddress, String studentFirstName, String studentLastName) { try {/*from www . j a v a 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 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); } }