List of usage examples for org.apache.commons.mail Email setFrom
public Email setFrom(final String email) throws EmailException
From source file:com.kylinolap.job.tools.MailService.java
public void sendMail(List<String> receivers, String subject, String content) throws IOException { Email email = new HtmlEmail(); email.setHostName(host);//w w w.j av a 2 s.c o m email.setDebug(true); try { for (String receiver : receivers) { email.addTo(receiver); } email.setFrom(sender); email.setSubject(subject); email.setCharset("UTF-8"); ((HtmlEmail) email).setHtmlMsg(content); email.send(); email.getMailSession(); System.out.println("!!"); } catch (EmailException e) { e.printStackTrace(); } }
From source file:br.com.jvmsoftware.util.EnviarMail.java
public void emailSimples(PubConfigEmpresa conf, PubUsuario usu, String msg, String subj) throws EmailException { Email email = new SimpleEmail(); email.setHostName(conf.getMailEnvioSmtp()); email.setSmtpPort(conf.getMailEnvioPorta()); email.setAuthenticator(new DefaultAuthenticator(conf.getMailEnvio(), conf.getMailEnvioSenha())); email.setSSLOnConnect(true);/*from w ww . j a va 2s. c om*/ email.setFrom(conf.getMailEnvio()); email.setSubject(subj); email.setMsg(msg); email.addTo(usu.getEmail()); email.send(); }
From source file:com.intuit.wasabi.email.impl.EmailServiceImpl.java
void send(String subject, String msg, String... to) { String[] clearTo = removeInvalidEmails(to); if (isActive()) { try {//from www . java 2 s .com Email email = createSimpleMailService(); email.setHostName(host); email.setFrom(from); email.setSubject(subjectPrefix + " " + subject); email.setMsg(msg); email.addTo(clearTo); email.send(); } catch (EmailException mailExcp) { LOGGER.error("Email could not be send because of " + mailExcp.getMessage()); throw new WasabiEmailException("Email: " + emailToString(subject, msg, to) + " could not be sent.", mailExcp); } } else { //if the service is not active log the email that would have been send and throw error LOGGER.info("EmailService would have sent: " + emailToString(subject, msg, to)); throw new WasabiEmailException(ErrorCode.EMAIL_NOT_ACTIVE_ERROR, "The EmailService is not active."); } }
From source file:com.cognifide.qa.bb.email.EmailSender.java
public void sendEmail(final EmailData emailData) { try {/*from w ww . j a va 2 s. com*/ Email email = new SimpleEmail(); email.setHostName(smtpServer); email.setSmtpPort(smtpPort); email.setAuthenticator(new DefaultAuthenticator(username, password)); email.setSSLOnConnect(secure); email.setFrom(emailData.getAddressFrom()); email.setSubject(emailData.getSubject()); email.setMsg(emailData.getMessageContent()); email.addTo(emailData.getAddressTo()); email.send(); } catch (org.apache.commons.mail.EmailException e) { throw new EmailException(e); } }
From source file:net.sasasin.sreader.batch.publish.GMailPublisher.java
@Override public void publish(ContentViewId content) { try {// w ww . j a v a2 s . c o m Email email = new SimpleEmail(); email.setHostName("smtp.gmail.com"); email.setSmtpPort(587); email.setStartTLSEnabled(true); email.setCharset("UTF-8"); email.setAuthenticator(new DefaultAuthenticator(content.getEmail(), content.getPassword())); email.setFrom(content.getEmail()); email.addTo(content.getEmail()); email.setSubject(content.getTitle()); email.setMsg(content.getUrl() + "\n" + content.getFullText()); email.send(); log(content); } catch (EmailException e) { e.printStackTrace(); } }
From source file:ch.unibas.fittingwizard.application.tools.Notifications.java
private void sendMailTesting() { try {//from www . j a v a 2 s .c o m Email email = new SimpleEmail(); email.setMailSession(Session.getDefaultInstance(props)); email.setSubject("Test mail"); email.setMsg("This is a test mail for checking parameters from config file"); email.setFrom(getSender().trim()); email.addTo(getRecipient().trim()); email.send(); } catch (EmailException e) { throw new RuntimeException("Could not send notification.", e); } }
From source file:ch.unibas.fittingwizard.application.tools.Notifications.java
private void sendErrorLogByMail() { try {/*w w w . j a va2 s.c o m*/ Email email = new SimpleEmail(); email.setMailSession(Session.getDefaultInstance(props)); email.setSubject("Log of FW session"); email.setMsg(new String(Files.readAllBytes(Paths.get("fw-log.txt")))); email.setFrom(getSender().trim()); email.addTo(getRecipient().trim()); email.send(); } catch (IOException | EmailException e) { throw new RuntimeException("Could not send notification.", e); } }
From source file:com.turn.sorcerer.util.email.Emailer.java
private void sendEmail() throws EmailException, UnknownHostException { List<String> addresses = Lists .newArrayList(Splitter.on(',').omitEmptyStrings().trimResults().split(ADMIN_EMAIL.getAdmins())); logger.info("Sending email to {}", addresses.toString()); Email email = new HtmlEmail(); email.setHostName(ADMIN_EMAIL.getHost()); email.setSocketTimeout(30000); // 30 seconds email.setSocketConnectionTimeout(30000); // 30 seconds for (String address : addresses) { email.addTo(address);/*w w w . j a va 2s .c om*/ } email.setFrom( SorcererInjector.get().getModule().getName() + "@" + InetAddress.getLocalHost().getHostName()); email.setSubject(title); email.setMsg(body); email.send(); }
From source file:ch.unibas.fittingwizard.application.tools.Notifications.java
private void sendMailGaussian(boolean isLogValid) { try {//from www .ja v a2s . c o m Email email = new SimpleEmail(); email.setMailSession(Session.getDefaultInstance(props)); email.setSubject("Gaussian calculation finished"); email.setMsg("Gaussian calculation finished. Log file validation returned: " + isLogValid); email.setFrom(getSender().trim()); email.addTo(getRecipient().trim()); email.send(); } catch (EmailException e) { throw new RuntimeException("Could not send notification.", e); } }
From source file:beanView.MbVListaEmail.java
public void sendMail() { String subject = nombre + " " + eMail; try {//from w w w .j av a 2s.c om Email email = new SimpleEmail(); email.setHostName("smtp.gmail.com"); email.setSmtpPort(465); email.setAuthenticator(new DefaultAuthenticator("altabar.listas", "Nivde017")); email.setSSLOnConnect(true); email.isStartTLSEnabled(); email.setFrom("altabar.listas@gmail.com"); email.setSubject(subject); email.setMsg(message); email.addTo("eacunagon@gmail.com"); email.send(); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Listo!", "Lista enviada")); } catch (Exception ex) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", ex.getMessage())); eMail = ""; nombre = ""; message = ""; } }