List of usage examples for org.apache.commons.mail HtmlEmail send
public String send() throws EmailException
From source file:com.perceptive.epm.perkolcentral.bl.EmployeeBL.java
private void sendMailToPerceptiveOpsTeam(EmployeeBO employeeBO) throws Exception { try {//from w w w . j av a 2s . co m //Send the mail HtmlEmail emailToSend = new HtmlEmail(); emailToSend.setHostName(email.getHostName()); String messageTemplateAdded = "<html>\n" + "<head>\n" + "</head>\n" + "\n" + "<body style=\"font:Georgia; font-size:12px;\">\n" + "<p>Dear All,</p>\n" + "<blockquote>\n" + " <p>A new employee has joined Perceptive Kolkata.</p>\n" + "</blockquote>\n" + "<ul>\n" + " <li><strong><em>User Name</em></strong>: <strong>%s</strong></li>\n" + " <li><em><strong>User Short Id</strong></em>: <strong>%s</strong></li>\n" + " <li><em><strong>Employee Id</strong></em>: <strong>%s</strong></li>\n" + " <li><strong><em>User Email-Id</em></strong>:<strong> %s</strong></li>\n" + " <li><em><strong>Mobile Number</strong></em>:<strong> %s</strong></li>\n" + " <li><em><strong>Job Title</strong></em> : <strong>%s</strong></li>\n" + "</ul>\n" + "<p>Please take following actions.</p>\n" + "<ul>\n" + " <li>Access to Rally.</li>\n" + " <li>Access to Salesforce.</li>\n" + " <li>Access to Confluence.</li>\n" + " <li>Access to Perceptive AD.</li>\n" + " <li>Access to TFS.</li>\n" + "</ul>\n" + "<p>Thanks,</p>\n" + "<blockquote>\n" + " <p>Perceptive Kolkata Central( http://10.195.17.14/PerceptiveKolkataCentral )</p>\n" + "</blockquote>\n" + "</body>\n" + "</html>"; String messageToSend = String.format(messageTemplateAdded, employeeBO.getEmployeeName(), employeeBO.getEmployeeUid(), employeeBO.getEmployeeId().toString(), employeeBO.getEmail(), employeeBO.getMobileNumber(), employeeBO.getJobTitle()); emailToSend.setHtmlMsg(messageToSend); //emailToSend.setTextMsg(StringEscapeUtils.escapeHtml(messageToSend)); emailToSend.getToAddresses().clear(); emailToSend.addTo("per.special.rad.operations@perceptivesoftware.com", "RAD - Operations"); emailToSend.addTo("radops@perceptivesoftware.com", "RAD - Operations Team"); Collection<EmployeeBO> allEmployeesNeedToGetMail = getAllEmployeesKeyedByGroupId() .get(Integer.valueOf("14")); for (EmployeeBO item : allEmployeesNeedToGetMail) { emailToSend.addCc(item.getEmail(), item.getEmployeeName()); } //emailToSend.setFrom("PerceptiveKolkataCentral@perceptivesoftware.com", "Perceptive Kolkata Central"); emailToSend.setFrom("EnterpriseSoftwareKolkata@lexmark.com", "Enterprise Software Kolkata"); emailToSend.setSubject( String.format("New employee joined @ Lexmark Kolkata : %s", employeeBO.getEmployeeName())); emailToSend.send(); } catch (Exception ex) { throw new ExceptionWrapper(ex); } }
From source file:de.hybris.platform.acceleratorservices.email.impl.DefaultEmailService.java
@Override public boolean send(final EmailMessageModel message) { if (message == null) { throw new IllegalArgumentException("message must not be null"); }//from w ww . ja v a 2 s. c o m final boolean sendEnabled = getConfigurationService().getConfiguration() .getBoolean(EMAILSERVICE_SEND_ENABLED_CONFIG_KEY, true); if (sendEnabled) { try { final HtmlEmail email = getPerConfiguredEmail(); email.setCharset("UTF-8"); final List<EmailAddressModel> toAddresses = message.getToAddresses(); if (CollectionUtils.isNotEmpty(toAddresses)) { email.setTo(getAddresses(toAddresses)); } else { throw new IllegalArgumentException("message has no To addresses"); } final List<EmailAddressModel> ccAddresses = message.getCcAddresses(); if (ccAddresses != null && !ccAddresses.isEmpty()) { email.setCc(getAddresses(ccAddresses)); } final List<EmailAddressModel> bccAddresses = message.getBccAddresses(); if (bccAddresses != null && !bccAddresses.isEmpty()) { email.setBcc(getAddresses(bccAddresses)); } final EmailAddressModel fromAddress = message.getFromAddress(); email.setFrom(fromAddress.getEmailAddress(), nullifyEmpty(fromAddress.getDisplayName())); // Add the reply to if specified final String replyToAddress = message.getReplyToAddress(); if (replyToAddress != null && !replyToAddress.isEmpty()) { email.setReplyTo(Collections.singletonList(createInternetAddress(replyToAddress, null))); } email.setSubject(message.getSubject()); email.setHtmlMsg(getBody(message)); // To support plain text parts use email.setTextMsg() final List<EmailAttachmentModel> attachments = message.getAttachments(); if (attachments != null && !attachments.isEmpty()) { for (final EmailAttachmentModel attachment : attachments) { try { final DataSource dataSource = new ByteArrayDataSource( getMediaService().getDataFromMedia(attachment), attachment.getMime()); email.attach(dataSource, attachment.getRealFileName(), attachment.getAltText()); } catch (final EmailException ex) { LOG.error("Failed to load attachment data into data source [" + attachment + "]", ex); return false; } } } // Important to log all emails sent out LOG.info("Sending Email [" + message.getPk() + "] To [" + convertToStrings(toAddresses) + "] From [" + fromAddress.getEmailAddress() + "] Subject [" + email.getSubject() + "]"); // Send the email and capture the message ID final String messageID = email.send(); message.setSent(true); message.setSentMessageID(messageID); message.setSentDate(new Date()); getModelService().save(message); return true; } catch (final EmailException e) { LOG.warn("Could not send e-mail pk [" + message.getPk() + "] subject [" + message.getSubject() + "] cause: " + e.getMessage()); if (LOG.isDebugEnabled()) { LOG.debug(e); } } } else { LOG.warn("Could not send e-mail pk [" + message.getPk() + "] subject [" + message.getSubject() + "]"); LOG.info("Email sending has been disabled. Check the config property 'emailservice.send.enabled'"); return true; } return false; }
From source file:gov.osti.services.Metadata.java
/** * Send a NOTIFICATION EMAIL (if configured) when a record is SUBMITTED or * ANNOUNCED./*ww w . j av a 2s.c o m*/ * * @param md the METADATA in question */ private static void sendStatusNotification(DOECodeMetadata md) { HtmlEmail email = new HtmlEmail(); email.setCharset(org.apache.commons.mail.EmailConstants.UTF_8); email.setHostName(EMAIL_HOST); // if EMAIL or DESTINATION ADDRESS are not set, abort if (StringUtils.isEmpty(EMAIL_HOST) || StringUtils.isEmpty(EMAIL_SUBMISSION)) return; // only applicable to SUBMITTED or ANNOUNCED records if (!Status.Announced.equals(md.getWorkflowStatus()) && !Status.Submitted.equals(md.getWorkflowStatus())) return; // get the SITE information String siteCode = md.getSiteOwnershipCode(); Site site = SiteServices.findSiteBySiteCode(siteCode); if (null == site) { log.warn("Unable to locate SITE information for SITE CODE: " + siteCode); return; } String lab = site.getLab(); lab = lab.isEmpty() ? siteCode : lab; try { email.setFrom(EMAIL_FROM); email.setSubject("DOE CODE Record " + md.getWorkflowStatus().toString()); email.addTo(EMAIL_SUBMISSION); String softwareTitle = md.getSoftwareTitle().replaceAll("^\\h+|\\h+$", ""); StringBuilder msg = new StringBuilder(); msg.append("<html>"); msg.append("A new DOE CODE record has been ").append(md.getWorkflowStatus()).append(" for ").append(lab) .append(" and is awaiting approval:"); msg.append("<P>Code ID: ").append(md.getCodeId()); msg.append("<BR>Software Title: ").append(softwareTitle); msg.append("</html>"); email.setHtmlMsg(msg.toString()); email.send(); } catch (EmailException e) { log.error("Failed to send submission/announcement notification message for #" + md.getCodeId()); log.error("Message: " + e.getMessage()); } }
From source file:com.baasbox.service.user.UserService.java
public static void sendResetPwdMail(String appCode, ODocument user) throws Exception { final String errorString = "Cannot send mail to reset the password: "; //check method input if (!user.getSchemaClass().getName().equalsIgnoreCase(UserDao.MODEL_NAME)) throw new PasswordRecoveryException(errorString + " invalid user object"); //initialization String siteUrl = Application.NETWORK_HTTP_URL.getValueAsString(); int sitePort = Application.NETWORK_HTTP_PORT.getValueAsInteger(); if (StringUtils.isEmpty(siteUrl)) throw new PasswordRecoveryException(errorString + " invalid site url (is empty)"); String textEmail = PasswordRecovery.EMAIL_TEMPLATE_TEXT.getValueAsString(); String htmlEmail = PasswordRecovery.EMAIL_TEMPLATE_HTML.getValueAsString(); if (StringUtils.isEmpty(htmlEmail)) htmlEmail = textEmail;/*from w ww . jav a 2s . c om*/ if (StringUtils.isEmpty(htmlEmail)) throw new PasswordRecoveryException(errorString + " text to send is not configured"); boolean useSSL = PasswordRecovery.NETWORK_SMTP_SSL.getValueAsBoolean(); boolean useTLS = PasswordRecovery.NETWORK_SMTP_TLS.getValueAsBoolean(); String smtpHost = PasswordRecovery.NETWORK_SMTP_HOST.getValueAsString(); int smtpPort = PasswordRecovery.NETWORK_SMTP_PORT.getValueAsInteger(); if (StringUtils.isEmpty(smtpHost)) throw new PasswordRecoveryException(errorString + " SMTP host is not configured"); String username_smtp = null; String password_smtp = null; if (PasswordRecovery.NETWORK_SMTP_AUTHENTICATION.getValueAsBoolean()) { username_smtp = PasswordRecovery.NETWORK_SMTP_USER.getValueAsString(); password_smtp = PasswordRecovery.NETWORK_SMTP_PASSWORD.getValueAsString(); if (StringUtils.isEmpty(username_smtp)) throw new PasswordRecoveryException(errorString + " SMTP username is not configured"); } String emailFrom = PasswordRecovery.EMAIL_FROM.getValueAsString(); String emailSubject = PasswordRecovery.EMAIL_SUBJECT.getValueAsString(); if (StringUtils.isEmpty(emailFrom)) throw new PasswordRecoveryException(errorString + " sender email is not configured"); try { String userEmail = ((ODocument) user.field(UserDao.ATTRIBUTES_VISIBLE_ONLY_BY_THE_USER)).field("email") .toString(); String username = (String) ((ODocument) user.field("user")).field("name"); //Random String sRandom = appCode + "%%%%" + username + "%%%%" + UUID.randomUUID(); String sBase64Random = new String(Base64.encodeBase64(sRandom.getBytes())); //Save on DB ResetPwdDao.getInstance().create(new Date(), sBase64Random, user); //Send mail HtmlEmail email = null; URL resetUrl = new URL(Application.NETWORK_HTTP_SSL.getValueAsBoolean() ? "https" : "http", siteUrl, sitePort, "/user/password/reset/" + sBase64Random); //HTML Email Text ST htmlMailTemplate = new ST(htmlEmail, '$', '$'); htmlMailTemplate.add("link", resetUrl); htmlMailTemplate.add("user_name", username); htmlMailTemplate.add("token", sBase64Random); //Plain text Email Text ST textMailTemplate = new ST(textEmail, '$', '$'); textMailTemplate.add("link", resetUrl); textMailTemplate.add("user_name", username); textMailTemplate.add("token", sBase64Random); email = new HtmlEmail(); email.setHtmlMsg(htmlMailTemplate.render()); email.setTextMsg(textMailTemplate.render()); //Email Configuration email.setSSL(useSSL); email.setSSLOnConnect(useSSL); email.setTLS(useTLS); email.setStartTLSEnabled(useTLS); email.setStartTLSRequired(useTLS); email.setSSLCheckServerIdentity(false); email.setSslSmtpPort(String.valueOf(smtpPort)); email.setHostName(smtpHost); email.setSmtpPort(smtpPort); email.setCharset("utf-8"); if (PasswordRecovery.NETWORK_SMTP_AUTHENTICATION.getValueAsBoolean()) { email.setAuthenticator(new DefaultAuthenticator(username_smtp, password_smtp)); } email.setFrom(emailFrom); email.addTo(userEmail); email.setSubject(emailSubject); if (BaasBoxLogger.isDebugEnabled()) { StringBuilder logEmail = new StringBuilder().append("HostName: ").append(email.getHostName()) .append("\n").append("SmtpPort: ").append(email.getSmtpPort()).append("\n") .append("SslSmtpPort: ").append(email.getSslSmtpPort()).append("\n") .append("SSL: ").append(email.isSSL()).append("\n").append("TLS: ").append(email.isTLS()) .append("\n").append("SSLCheckServerIdentity: ").append(email.isSSLCheckServerIdentity()) .append("\n").append("SSLOnConnect: ").append(email.isSSLOnConnect()).append("\n") .append("StartTLSEnabled: ").append(email.isStartTLSEnabled()).append("\n") .append("StartTLSRequired: ").append(email.isStartTLSRequired()).append("\n") .append("SubType: ").append(email.getSubType()).append("\n") .append("SocketConnectionTimeout: ").append(email.getSocketConnectionTimeout()).append("\n") .append("SocketTimeout: ").append(email.getSocketTimeout()).append("\n") .append("FromAddress: ").append(email.getFromAddress()).append("\n").append("ReplyTo: ") .append(email.getReplyToAddresses()).append("\n").append("BCC: ") .append(email.getBccAddresses()).append("\n").append("CC: ").append(email.getCcAddresses()) .append("\n") .append("Subject: ").append(email.getSubject()).append("\n") //the following line throws a NPE in debug mode //.append("Message: ").append(email.getMimeMessage().getContent()).append("\n") .append("SentDate: ").append(email.getSentDate()).append("\n"); BaasBoxLogger.debug("Password Recovery is ready to send: \n" + logEmail.toString()); } email.send(); } catch (EmailException authEx) { BaasBoxLogger.error("ERROR SENDING MAIL:" + ExceptionUtils.getStackTrace(authEx)); throw new PasswordRecoveryException( errorString + " Could not reach the mail server. Please contact the server administrator"); } catch (Exception e) { BaasBoxLogger.error("ERROR SENDING MAIL:" + ExceptionUtils.getStackTrace(e)); throw new Exception(errorString, e); } }
From source file:gov.osti.services.Metadata.java
/** * Send a POC email notification on SUBMISSION/APPROVAL of DOE CODE records. * * @param md the METADATA to send notification for *//*from w w w .jav a2 s . c o m*/ private static void sendPOCNotification(DOECodeMetadata md) { // if HOST or MD or PROJECT MANAGER NAME isn't set, cannot send if (StringUtils.isEmpty(EMAIL_HOST) || null == md || StringUtils.isEmpty(PM_NAME)) return; Long codeId = md.getCodeId(); String siteCode = md.getSiteOwnershipCode(); Status workflowStatus = md.getWorkflowStatus(); // if SITE OWNERSHIP isn't set, cannot send if (StringUtils.isEmpty(siteCode)) return; // only applicable to APPROVED records if (!Status.Approved.equals(workflowStatus)) return; // get the SITE information Site site = SiteServices.findSiteBySiteCode(siteCode); if (null == site) { log.warn("Unable to locate SITE information for SITE CODE: " + siteCode); return; } // lookup previous Snapshot status info for item EntityManager em = DoeServletContextListener.createEntityManager(); TypedQuery<MetadataSnapshot> querySnapshot = em .createNamedQuery("MetadataSnapshot.findByCodeIdLastNotStatus", MetadataSnapshot.class) .setParameter("status", DOECodeMetadata.Status.Approved).setParameter("codeId", codeId); String lastApprovalFor = "submitted/announced"; List<MetadataSnapshot> results = querySnapshot.setMaxResults(1).getResultList(); for (MetadataSnapshot ms : results) { lastApprovalFor = ms.getSnapshotKey().getSnapshotStatus().toString().toLowerCase(); } List<String> emails = site.getPocEmails(); // if POC is setup if (emails != null && !emails.isEmpty()) { try { HtmlEmail email = new HtmlEmail(); email.setCharset(org.apache.commons.mail.EmailConstants.UTF_8); email.setHostName(EMAIL_HOST); String lab = site.getLab(); lab = lab.isEmpty() ? siteCode : lab; String softwareTitle = md.getSoftwareTitle().replaceAll("^\\h+|\\h+$", ""); email.setFrom(EMAIL_FROM); email.setSubject("POC Notification -- " + workflowStatus + " -- DOE CODE ID: " + codeId + ", " + softwareTitle); for (String pocEmail : emails) email.addTo(pocEmail); // if email is provided, BCC the Project Manager if (!StringUtils.isEmpty(PM_EMAIL)) email.addBcc(PM_EMAIL, PM_NAME); StringBuilder msg = new StringBuilder(); msg.append("<html>"); msg.append("Dear Sir or Madam:"); String biblioLink = SITE_URL + "/biblio/" + codeId; msg.append("<p>As a point of contact for ").append(lab) .append(", we wanted to inform you that a software project, titled ").append(softwareTitle) .append(", associated with your organization was ").append(lastApprovalFor) .append(" to DOE CODE and assigned DOE CODE ID: ").append(codeId) .append(". This project record is discoverable in <a href=\"").append(SITE_URL) .append("\">DOE CODE</a>, e.g. searching by the project title or DOE CODE ID #, and can be found here: <a href=\"") .append(biblioLink).append("\">").append(biblioLink).append("</a></p>"); msg.append( "<p>If you have any questions, please do not hesitate to <a href=\"mailto:doecode@osti.gov\">Contact Us</a>.</p>"); msg.append("<p>Sincerely,</p>"); msg.append("<p>").append(PM_NAME).append("<br/>Product Manager for DOE CODE<br/>USDOE/OSTI</p>"); msg.append("</html>"); email.setHtmlMsg(msg.toString()); email.send(); } catch (EmailException e) { log.error("Unable to send POC notification to " + Arrays.toString(emails.toArray()) + " for #" + md.getCodeId()); log.error("Message: " + e.getMessage()); } } }
From source file:bean.OrdemBean.java
private void enviarEmailOrdem(OrdOrdem ordemNova, boolean novaOrdem) { try {//from ww w. j a va2 s . c om String emailAutenticacao = "chravent@gmail.com"; String senhaAutenticacao = "23421Felix"; //MultiPartEmail email = new MultiPartEmail(); HtmlEmail emailOrdem = new HtmlEmail(); //Informaes do Servidor emailOrdem.setHostName("smtp.gmail.com"); emailOrdem.setSmtpPort(587); //DADOS DE QUEM ESTA ENVIANDO O E-MAIL emailOrdem.setFrom(emailAutenticacao, "GESPED"); //PARA QUEM VAI O EMAIL, VC PODE COLOCAR O USUARIO DE CRIACAO, O QUE ACOMPANHA E O ALTERACO if (!novaOrdem) { if (ordemNova.getUsuUsuarioByUsuAcompanha() != null) { emailOrdem.addTo(ordemNova.getUsuUsuarioByUsuAcompanha().getUsuEmail(), ordemNova.getUsuUsuarioByUsuAcompanha().getUsuUsuario()); emailOrdem.setSubject("Atribuio de Ordem - Com Acompanhamento"); } else { emailOrdem.addTo(ordemNova.getDepDepartamentoByDepIdDestino().getDepEmail(), ordemNova.getUsuUsuarioByUsuCriacao().getUsuUsuario()); emailOrdem.setSubject("Atribuio de Ordem - Sem Acompanhamento"); } } else { emailOrdem.addTo(ordemNova.getUsuUsuarioByUsuCriacao().getUsuEmail(), ordemNova.getUsuUsuarioByUsuAcompanha().getUsuUsuario()); emailOrdem.setSubject("Criao de Nova de Ordem"); } emailOrdem.setSocketConnectionTimeout(30000); emailOrdem.setSocketTimeout(30000); //if (contaPadrao.contains("gmail")) { emailOrdem.setSSL(true); emailOrdem.setTLS(true); //Autenticando no servidor emailOrdem.setAuthentication(emailAutenticacao, senhaAutenticacao); //Montando o e-mail StringBuilder htmlEmail = new StringBuilder(); htmlEmail.append( "<html> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" /> </head><body>"); htmlEmail.append("<br/>").append("Ol ").append(ordem.getUsuUsuarioByUsuAcompanha().getUsuDescricao()) .append(",").append("<br/>"); htmlEmail.append("Uma Ordem Atribuda para seu Usurio:").append("<br/>"); htmlEmail.append("Protocolo : ").append(ordem.getOrdNumProtocolo()).append("<br/>"); if (ordem.getOrdPrioridade()) { htmlEmail.append("Prioridade : Urgente").append("<br/>"); } else { htmlEmail.append("Prioridade : Normal").append("<br/>"); } htmlEmail.append("\"</body></html>\""); //PODE ENVIAR UMA COPIA OCULPA emailOrdem.setHtmlMsg(htmlEmail.toString()); // List<InternetAddress> copiasOcultas = new ArrayList<>(); // copiasOcultas.add(new InternetAddress("enio.a.nunes@gmail.com")); // emailOrdem.setBcc(copiasOcultas); emailOrdem.send(); // context.addMessage(null, new FacesMessage("E-mail enviado com sucesso", this.destino)); } catch (Exception e) { e.printStackTrace(); } }
From source file:gov.osti.services.Metadata.java
/** * Send an email notification on APPROVAL of DOE CODE records. * * @param md the METADATA to send notification for *//*from www. j a v a2 s . com*/ private static void sendApprovalNotification(DOECodeMetadata md) { HtmlEmail email = new HtmlEmail(); email.setCharset(org.apache.commons.mail.EmailConstants.UTF_8); email.setHostName(EMAIL_HOST); // if HOST or record OWNER or PROJECT MANAGER NAME isn't set, cannot send if (StringUtils.isEmpty(EMAIL_HOST) || null == md || StringUtils.isEmpty(md.getOwner()) || StringUtils.isEmpty(PM_NAME)) return; // only has meaning for APPROVED records if (!Status.Approved.equals(md.getWorkflowStatus())) return; try { // get the OWNER information User owner = UserServices.findUserByEmail(md.getOwner()); if (null == owner) { log.warn("Unable to locate USER information for Code ID: " + md.getCodeId()); return; } Long codeId = md.getCodeId(); // lookup previous Snapshot status info for item EntityManager em = DoeServletContextListener.createEntityManager(); TypedQuery<MetadataSnapshot> querySnapshot = em .createNamedQuery("MetadataSnapshot.findByCodeIdLastNotStatus", MetadataSnapshot.class) .setParameter("status", DOECodeMetadata.Status.Approved).setParameter("codeId", codeId); String lastApprovalFor = "submitted/announced"; List<MetadataSnapshot> results = querySnapshot.setMaxResults(1).getResultList(); for (MetadataSnapshot ms : results) { lastApprovalFor = ms.getSnapshotKey().getSnapshotStatus().toString().toLowerCase(); } String softwareTitle = md.getSoftwareTitle().replaceAll("^\\h+|\\h+$", ""); email.setFrom(EMAIL_FROM); email.setSubject("Approved -- DOE CODE ID: " + codeId + ", " + softwareTitle); email.addTo(md.getOwner()); // if email is provided, BCC the Project Manager if (!StringUtils.isEmpty(PM_EMAIL)) email.addBcc(PM_EMAIL, PM_NAME); StringBuilder msg = new StringBuilder(); msg.append("<html>"); msg.append("Dear ").append(owner.getFirstName()).append(" ").append(owner.getLastName()).append(":"); msg.append("<P>Thank you -- your ").append(lastApprovalFor).append(" project, DOE CODE ID: <a href=\"") .append(SITE_URL).append("/biblio/").append(codeId).append("\">").append(codeId) .append("</a>, has been approved. It is now <a href=\"").append(SITE_URL) .append("\">searchable</a> in DOE CODE by, for example, title or CODE ID #.</P>"); // OMIT the following for BUSINESS TYPE software, or last ANNOUNCED software if (!DOECodeMetadata.Type.B.equals(md.getSoftwareType()) && !lastApprovalFor.equalsIgnoreCase("announced")) { msg.append( "<P>You may need to continue editing your project to announce it to the Department of Energy ") .append("to ensure announcement and dissemination in accordance with DOE statutory responsibilities. For more information please see ") .append("<a href=\"").append(SITE_URL) .append("/faq#what-does-it-mean-to-announce\">What does it mean to announce scientific code to DOE CODE?</a></P>"); } msg.append( "<P>If you have questions such as What are the benefits of getting a DOI for code or software?, see the ") .append("<a href=\"").append(SITE_URL).append("/faq\">DOE CODE FAQs</a>.</P>"); msg.append( "<P>If we can be of assistance, please do not hesitate to <a href=\"mailto:doecode@osti.gov\">Contact Us</a>.</P>"); msg.append("<P>Sincerely,</P>"); msg.append("<P>").append(PM_NAME).append("<BR/>Product Manager for DOE CODE<BR/>USDOE/OSTI</P>"); msg.append("</html>"); email.setHtmlMsg(msg.toString()); email.send(); } catch (EmailException e) { log.error("Unable to send APPROVAL notification for #" + md.getCodeId()); log.error("Message: " + e.getMessage()); } }
From source file:email.cadastro.EmailCadastro.java
public boolean EnviarCodConfirmacao(String codigo, String emailCadastro) { HtmlEmail email = new HtmlEmail(); email.setSSLOnConnect(true);/* w ww .j av a2s.c om*/ email.setHostName("smtp.gmail.com"); //email.setSslSmtpPort("465"); email.setAuthenticator(new DefaultAuthenticator("contatogamesapp@gmail.com", "gamesifsul")); try { email.setFrom("contatogamesapp@gmail.com", "Equipe GamesApp"); email.setDebug(true); email.setSubject("Cdigo de confirmao"); String emailHtml = "<!doctype html><html><head><meta charset=\"UTF-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><title>Email</title></head><style type=\"text/css\">p{margin:10px 0;padding:0;}table{border-collapse:collapse;}h1,h2,h3,h4,h5,h6{display:block;margin:0;padding:0;}img,a img{border:0;height:auto;outline:none;text-decoration:none;}body,#bodyTable,#bodyCell{height:100%;margin:0;padding:0;width:100%;}#outlook a{padding:0;}img{-ms-interpolation-mode:bicubic;}table{mso-table-lspace:0pt;mso-table-rspace:0pt;}.ReadMsgBody{width:100%;}.ExternalClass{width:100%;}p,a,li,td,blockquote{mso-line-height-rule:exactly;}a[href^=tel],a[href^=sms]{color:inherit;cursor:default;text-decoration:none;}p,a,li,td,body,table,blockquote{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;}.ExternalClass,.ExternalClass p,.ExternalClass td,.ExternalClass div,.ExternalClass span,.ExternalClass font{line-height:100%;}a[x-apple-data-detectors]{color:inherit !important;text-decoration:none !important;font-size:inherit !important;font-family:inherit !important;font-weight:inherit !important;line-height:inherit !important;}#bodyCell{padding:10px;}.templateContainer{max-width:600px !important;}a.mcnButton{display:block;}.mcnImage{vertical-align:bottom;}.mcnTextContent{word-break:break-word;}.mcnTextContent img{height:auto !important;}.mcnDividerBlock{table-layout:fixed !important;}body,#bodyTable{background-color:#FAFAFA;}#bodyCell{border-top:0;}.templateContainer{border:0;}h1{color:#616161;font-family:Helvetica;font-size:22px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left;}h2{color:#202020;font-family:Helvetica;font-size:22px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left;}h3{color:#202020;font-family:Helvetica;font-size:20px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left;}h4{color:#202020;font-family:Helvetica;font-size:18px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:normal;text-align:left;}#templatePreheader{background-color:#FAFAFA;border-top:0;border-bottom:0;padding-top:20px;padding-bottom:20px;}#templatePreheader .mcnTextContent,#templatePreheader .mcnTextContent p{color:#656565;font-family:Helvetica;font-size:12px;line-height:150%;text-align:left;}#templatePreheader .mcnTextContent a,#templatePreheader .mcnTextContent p a{color:#656565;font-weight:normal;text-decoration:underline;}#templateHeader{background-color:#FFFFFF;border-top:0;border-bottom:0;padding-top:9px;padding-bottom:0;}#templateHeader .mcnTextContent,#templateHeader .mcnTextContent p{color:#202020;font-family:Helvetica;font-size:16px;line-height:150%;text-align:left;}#templateHeader .mcnTextContent a,#templateHeader .mcnTextContent p a{color:#2BAADF;font-weight:normal;text-decoration:underline;}#templateBody{background-color:#FFFFFF;border-top:0;border-bottom:2px solid #EAEAEA;padding-top:0;padding-bottom:9px;}#templateBody .mcnTextContent,#templateBody .mcnTextContent p{color:#616161;font-family:Helvetica;font-size:16px;line-height:150%;text-align:left;}#templateBody .mcnTextContent a,#templateBody .mcnTextContent p a{color:#2BAADF;font-weight:normal;text-decoration:underline;}#templateFooter{background-color:#FAFAFA;border-top:0;border-bottom:0;padding-top:9px;padding-bottom:9px;}#templateFooter .mcnTextContent,#templateFooter .mcnTextContent p{color:#656565;font-family:Helvetica;font-size:12px;line-height:150%;text-align:center;}#templateFooter .mcnTextContent a,#templateFooter .mcnTextContent p a{color:#656565;font-weight:normal;text-decoration:underline;}button{background: #107a49; border: none; padding: 10px 20px; border-radius: 70px; color: #fff;margin-top: 30px;cursor: pointer;}@media only screen and (min-width:768px){.templateContainer{width:600px !important;}}@media only screen and (max-width: 480px){body,table,td,p,a,li,blockquote{-webkit-text-size-adjust:none !important;}}@media only screen and (max-width: 480px){body{width:100% !important;min-width:100% !important;}}@media only screen and (max-width: 480px){#bodyCell{padding-top:10px !important;}}@media only screen and (max-width: 480px){.mcnImage{width:100% !important;}}@media only screen and (max-width: 480px){.mcnCartContainer,.mcnCaptionTopContent,.mcnRecContentContainer,.mcnCaptionBottomContent,.mcnTextContentContainer,.mcnBoxedTextContentContainer,.mcnImageGroupContentContainer,.mcnCaptionLeftTextContentContainer,.mcnCaptionRightTextContentContainer,.mcnCaptionLeftImageContentContainer,.mcnCaptionRightImageContentContainer,.mcnImageCardLeftTextContentContainer,.mcnImageCardRightTextContentContainer{max-width:100% !important;width:100% !important;}}@media only screen and (max-width: 480px){.mcnBoxedTextContentContainer{min-width:100% !important;}}@media only screen and (max-width: 480px){.mcnImageGroupContent{padding:9px !important;}}@media only screen and (max-width: 480px){.mcnCaptionLeftContentOuter .mcnTextContent,.mcnCaptionRightContentOuter .mcnTextContent{padding-top:9px !important;}}@media only screen and (max-width: 480px){.mcnImageCardTopImageContent,.mcnCaptionBlockInner .mcnCaptionTopContent:last-child .mcnTextContent{padding-top:18px !important;}}@media only screen and (max-width: 480px){.mcnImageCardBottomImageContent{padding-bottom:9px !important;}}@media only screen and (max-width: 480px){.mcnImageGroupBlockInner{padding-top:0 !important;padding-bottom:0 !important;}}@media only screen and (max-width: 480px){.mcnImageGroupBlockOuter{padding-top:9px !important;padding-bottom:9px !important;}}@media only screen and (max-width: 480px){.mcnTextContent,.mcnBoxedTextContentColumn{padding-right:18px !important;padding-left:18px !important;}}@media only screen and (max-width: 480px){.mcnImageCardLeftImageContent,.mcnImageCardRightImageContent{padding-right:18px !important;padding-bottom:0 !important;padding-left:18px !important;}}@media only screen and (max-width: 480px){.mcpreview-image-uploader{display:none !important;width:100% !important;}}@media only screen and (max-width: 480px){h1{font-size:22px !important;line-height:125% !important;}}@media only screen and (max-width: 480px){h2{font-size:20px !important;line-height:125% !important;}}@media only screen and (max-width: 480px){h3{font-size:18px !important;line-height:125% !important;}}@media only screen and (max-width: 480px){h4{font-size:16px !important;line-height:150% !important;}}@media only screen and (max-width: 480px){.mcnBoxedTextContentContainer .mcnTextContent,.mcnBoxedTextContentContainer .mcnTextContent p{font-size:14px !important;line-height:150% !important;}}@media only screen and (max-width: 480px){#templatePreheader{display:block !important;}}@media only screen and (max-width: 480px){#templatePreheader .mcnTextContent,#templatePreheader .mcnTextContent p{font-size:14px !important;line-height:150% !important;}}@media only screen and (max-width: 480px){#templateHeader .mcnTextContent,#templateHeader .mcnTextContent p{font-size:16px !important;line-height:150% !important;}}@media only screen and (max-width: 480px){#templateBody .mcnTextContent,#templateBody .mcnTextContent p{font-size:16px !important;line-height:150% !important;}}@media only screen and (max-width: 480px){#templateFooter .mcnTextContent,#templateFooter .mcnTextContent p{font-size:14px !important;line-height:150% !important;}}</style><body><center><table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" height=\"100%\" width=\"100%\" id=\"bodyTable\"><tr><td align=\"center\" valign=\"top\" id=\"bodyCell\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"templateContainer\"><tr><td valign=\"top\" id=\"templatePreheader\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnImageBlock\" style=\"min-width:100%;\"><tbody class=\"mcnImageBlockOuter\"><tr><td valign=\"top\" style=\"padding:9px\" class=\"mcnImageBlockInner\"><table align=\"left\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"mcnImageContentContainer\" style=\"min-width:100%;\"><tbody><tr><td class=\"mcnImageContent\" valign=\"top\" style=\"padding-right: 9px; padding-left: 9px; padding-top: 0; padding-bottom: 0;\"><a href=\"https://github.com/GamesApp\" target=\"_blank\"><img align=\"left\" alt=\"\" src=\"https://ap.imagensbrasil.org/images/2016/11/21/logo_escrita.png\" width=\"200\" style=\"max-width:200px; padding-bottom: 0; display: inline !important; vertical-align: bottom;\" class=\"mcnImage\"></a></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr><td valign=\"top\" id=\"templateBody\" style=\"border-radius:5px;\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnTextBlock\" style=\"min-width:100%;\"><tbody class=\"mcnTextBlockOuter\"><tr><td valign=\"top\" class=\"mcnTextBlockInner\" style=\"padding-top:9px;\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"max-width:100%; min-width:100%;\" width=\"100%\" class=\"mcnTextContentContainer\"><tbody><tr><td valign=\"top\" class=\"mcnTextContent\" style=\"padding-top:30px; padding-right:30px; padding-bottom:30px; padding-left:30px;\"><h1>Cdigo de confirmao</h1><p>E a, tudo certo?!</p><p>Recebemos uma solicitao de cadastro no aplicativo GamesApp.</p><p>Segue o cdigo de confirmao:</p><div style=\"background: #CCCCCC; text-align: center; border-radius:5px; padding-top: 9px; padding-bottom: 9px;\">" + codigo + "</div><p style=\"font-size: 10px; \">Obs.: Se voc no realizou est operao entrar em contato o mais rpido possvel!</p></td></tr></tbody></table></td></tr></tbody></table><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnDividerBlock\" style=\"min-width:100%;\"><tbody class=\"mcnDividerBlockOuter\"><tr><td class=\"mcnDividerBlockInner\" style=\"min-width:100%; padding:18px 30px;\"><table class=\"mcnDividerContent\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"min-width: 100%;border-top: 2px dashed #EAEAEA;\"><tbody><tr><td><span></span></td></tr></tbody></table></td></tr></tbody></table><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnFollowBlock\" style=\"min-width:100%;\"><tbody class=\"mcnFollowBlockOuter\"><tr><td align=\"center\" valign=\"top\" style=\"padding:9px\" class=\"mcnFollowBlockInner\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnFollowContentContainer\" style=\"min-width:100%;\"><tbody><tr><td align=\"center\" style=\"padding-left:9px;padding-right:9px;\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"min-width:100%;\" class=\"mcnFollowContent\"><tbody><tr><td align=\"center\" valign=\"top\" style=\"padding-top:9px; padding-right:9px; padding-left:9px;\"><table align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr><td align=\"center\" valign=\"top\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"display:inline;\"><tbody><tr><td valign=\"top\" style=\"padding-right:0; padding-bottom:9px;\" class=\"mcnFollowContentItemContainer\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnFollowContentItem\"><tbody><tr><td align=\"left\" valign=\"middle\" style=\"padding-top:5px; padding-right:10px; padding-bottom:5px; padding-left:9px;\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"\"><tbody><tr><td align=\"center\" valign=\"middle\" width=\"24\" class=\"mcnFollowIconContent\"><a href=\"https://github.com/GamesApp\" target=\"_blank\"><img src=\"http://oi63.tinypic.com/30sk57c.jpg\" style=\"display:block;\" height=\"24\" width=\"24\" class=\"\"></a></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr><td valign=\"top\" id=\"templateFooter\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"mcnTextBlock\" style=\"min-width:100%;\"><tbody class=\"mcnTextBlockOuter\"><tr><td valign=\"top\" class=\"mcnTextBlockInner\" style=\"padding-top:9px;\"><table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"max-width:100%; min-width:100%;\" width=\"100%\" class=\"mcnTextContentContainer\"><tbody><tr><td valign=\"top\" class=\"mcnTextContent\" style=\"padding-top:0; padding-right:18px; padding-bottom:9px; padding-left:18px;\"><em> GamesApp. Todos os direitos reservados. </em><br><br></td></tr></tbody></table></td></tr></tbody></table></td></tr></table></td></tr></table></center></body></html>"; email.setHtmlMsg(emailHtml); email.addTo(emailCadastro); email.send(); } catch (EmailException e) { return false; } return true; }
From source file:net.wildpark.dswp.supports.MailService.java
public boolean sendEmail(String to, String textBody) { try {/* w w w. j av a 2s . c o m*/ HtmlEmail email = new HtmlEmail(); email.setCharset("utf-8"); email.setHostName("mail.wildpark.net"); email.setSmtpPort(25); email.setAuthenticator(new DefaultAuthenticator("informer@mksat.net", "22v5C728")); email.setFrom("informer@mksat.net"); email.setSubject("Automatic message from darkside.wildpark.net"); email.setHtmlMsg(textBody); email.addTo(to); email.send(); logFacade.create(new Log("Sended mail " + to)); } catch (EmailException ex) { logFacade.create(new Log("Error with mail sending", ex, LoggerLevel.ERROR)); System.out.println(ex); return false; } return true; }
From source file:nl.b3p.kaartenbalie.struts.Mailer.java
public ActionMessages send(ActionMessages errors) throws AddressException, MessagingException, IOException, Exception { HtmlEmail email = new HtmlEmail(); String[] ds = null;// ww w . j ava 2 s . c o m if (mailTo != null && mailTo.trim().length() != 0) { ds = mailTo.split(","); for (int i = 0; i < ds.length; i++) { email.addTo(ds[i]); } } if (mailCc != null && mailCc.trim().length() != 0) { ds = mailCc.split(","); for (int i = 0; i < ds.length; i++) { email.addCc(ds[i]); } } if (mailBcc != null && mailBcc.trim().length() != 0) { ds = mailBcc.split(","); for (int i = 0; i < ds.length; i++) { email.addBcc(ds[i]); } } email.setFrom(mailFrom); email.setSubject(subject); email.setHostName(mailHost); if (isReturnReceipt()) { email.addHeader("Disposition-Notification-To", mailFrom); } if (attachmentName == null) { attachmentName = "attachment"; } if (attachment != null) { URL attachUrl = null; try { attachUrl = new URL(attachment); email.attach(attachUrl, attachmentName, attachmentName); } catch (MalformedURLException mfue) { } } if (attachmentDataSource != null) { email.attach(attachmentDataSource, attachmentName, attachmentName); } email.setMsg(createHTML()); // send the email email.send(); return errors; }