Examples of HtmlEmail


Examples of org.apache.commons.mail.HtmlEmail

    with("host", appLocation);
    if (!hasSigner) {
      with("signer", bundle.getMessage("signer"));
    }

    HtmlEmail email = new HtmlEmail();
    try {
      addEmbeddables(email);
      addAttachments(email);
      email.addTo(toMail, name);
      email.setSubject(bundle.getMessage(this.templateName, nameParameters));
      email.setHtmlMsg(this.template.getContent());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return email;
  }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

      throw new ActivitiException("'html' or 'text' is required to be defined when using the mail activity");
    }
  }

  protected HtmlEmail createHtmlEmail(String text, String html) {
    HtmlEmail email = new HtmlEmail();
    try {
      email.setHtmlMsg(html);
      if (text != null) { // for email clients that don't support html
        email.setTextMsg(text);
      }
      return email;
    } catch (EmailException e) {
      throw new ActivitiException("Could not create HTML email", e);
    }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

    with("host", appLocation);
    if (!hasSigner) {
      with("signer", this.localization.getMessage("signer"));
    }

    HtmlEmail email = new HtmlEmail();
    email.setCharset("utf-8");
   
    try {
     
      addEmbeddables(email);
      addAttachments(email);
     
      email.addTo(toMail, name);
      boolean hasNoSubjectDefined = this.localization.getMessage(name,
          nameParameters).equals("???" + name + "???");
      if (hasNoSubjectDefined) {
        throw new IllegalArgumentException(
            "Subject not defined for email template : " + name);
      } else {
        email.setSubject(this.localization.getMessage(this.templateName, nameParameters));
      }
      email.setHtmlMsg(this.template.getContent());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return email;
  }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

            return;
        }

        Email email = (Email) object;

        final HtmlEmail htmlEmail = new HtmlEmail();

        try {
            htmlEmail.setFrom(Config.getEmailFromSmtp(), utils.Config.getSiteName());
            htmlEmail.addTo(email.email, email.user.name);
            htmlEmail.setSubject(Messages.get("emails.validation.email.title", utils.Config.getSiteName()));
            htmlEmail.setHtmlMsg(getMessage(email.confirmUrl));
            htmlEmail.setCharset("utf-8");
            Mailer.send(htmlEmail);
            String escapedTitle = htmlEmail.getSubject().replace("\"", "\\\"");
            String logEntry = String.format("\"%s\" %s", escapedTitle, htmlEmail.getToAddresses());
            play.Logger.of("mail").info(logEntry);
        } catch (Exception e) {
            Logger.warn("Failed to send a notification: "
                    + email + "\n" + ExceptionUtils.getStackTrace(e));
        }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

        }
        return internalServerError();
    }

    private static void sendTransferRequestMail(ProjectTransfer pt) {
        HtmlEmail email = new HtmlEmail();
        try {
            String acceptUrl = pt.getAcceptUrl();
            String message = Messages.get("transfer.message.hello", pt.destination) + "\n\n"
                    + Messages.get("transfer.message.detail", pt.project.name, pt.newProjectName, pt.project.owner, pt.destination) + "\n"
                    + Messages.get("transfer.message.link") + "\n\n"
                    + acceptUrl + "\n\n"
                    + Messages.get("transfer.message.deadline") + "\n\n"
                    + Messages.get("transfer.message.thank");

            email.setFrom(Config.getEmailFromSmtp(), pt.sender.name);
            email.addTo(Config.getEmailFromSmtp(), "Yobi");

            User to = User.findByLoginId(pt.destination);
            if (!to.isAnonymous()) {
                email.addBcc(to.email, to.name);
            }

            Organization org = Organization.findByName(pt.destination);
            if (org != null) {
                List<OrganizationUser> admins = OrganizationUser.findAdminsOf(org);
                for(OrganizationUser admin : admins) {
                    email.addBcc(admin.user.email, admin.user.name);
                }
            }

            email.setSubject(String.format("[%s] @%s wants to transfer project", pt.project.name, pt.sender.loginId));
            email.setHtmlMsg(Markdown.render(message));
            email.setTextMsg(message);
            email.setCharset("utf-8");
            email.addHeader("References", "<" + acceptUrl + "@" + Config.getHostname() + ">");
            email.setSentDate(pt.requested);
            Mailer.send(email);
            String escapedTitle = email.getSubject().replace("\"", "\\\"");
            String logEntry = String.format("\"%s\" %s", escapedTitle, email.getBccAddresses());
            play.Logger.of("mail").info(logEntry);
        } catch (Exception e) {
            Logger.warn("Failed to send a notification: " + email + "\n" + ExceptionUtils.getStackTrace(e));
        }
    }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

                usersByLang.put(lang, new ArrayList<>(Arrays.asList(receiver)));
            }
        }

        for (String langCode : usersByLang.keySet()) {
            final HtmlEmail email = new HtmlEmail();

            try {
                email.setFrom(Config.getEmailFromSmtp(), event.getSender().name);
                email.addTo(Config.getEmailFromSmtp(), utils.Config.getSiteName());

                for (User receiver : usersByLang.get(langCode)) {
                    email.addBcc(receiver.email, receiver.name);
                }

                Lang lang = Lang.apply(langCode);

                String message = event.getMessage(lang);
                String urlToView = Url.create(event.getUrlToView());
                String reference = Url.removeFragment(event.getUrlToView());

                email.setSubject(event.title);
                email.setHtmlMsg(getHtmlMessage(lang, message, urlToView, event.getResource()));
                email.setTextMsg(getPlainMessage(lang, message, urlToView));
                email.setCharset("utf-8");
                email.addHeader("References", "<" + reference + "@" + Config.getHostname() + ">");
                email.setSentDate(event.created);
                Mailer.send(email);
                String escapedTitle = email.getSubject().replace("\"", "\\\"");
                String logEntry = String.format("\"%s\" %s", escapedTitle, email.getBccAddresses());
                play.Logger.of("mail").info(logEntry);
            } catch (Exception e) {
                Logger.warn("Failed to send a notification: "
                        + email + "\n" + ExceptionUtils.getStackTrace(e));
            }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

    with("host", appLocation);
    if (!hasSigner) {
      with("signer", this.localization.getMessage("signer"));
    }

    HtmlEmail email = new HtmlEmail();
    email.setCharset("utf-8");
   
    try {
     
      addEmbeddables(email);
      addAttachments(email);
     
      email.addTo(toMail, name);
      email.setSubject(this.localization.getMessage(this.templateName, nameParameters));
      email.setHtmlMsg(this.template.getContent());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return email;
  }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

        notifiers.Welcome.welcome3();
        renderText("OK4");
    }

    public static void mail5() throws EmailException {
        HtmlEmail email = new HtmlEmail();
        email.setHtmlMsg("<html><body><h1>A Title</h1></body></html>");
        email.setTextMsg("alternative message");
        EmailAttachment attachment = new EmailAttachment();
        attachment.setDescription("An image");
        attachment.setDisposition(EmailAttachment.ATTACHMENT);
        attachment.setPath(Play.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond2.png");
        EmailAttachment attachment2 = new EmailAttachment();
        attachment2.setName("fond3.jpg");
        attachment2.setPath(Play.applicationPath.getPath() + java.io.File.separator + "test" + java.io.File.separator + "fond3.jpg");
        email.attach(attachment);
        email.attach(attachment2);
        email.setFrom("test@localhost");
        email.addTo("test@localhost");
        email.setSubject("test attachments");
        Mail.send(email);
        renderText("OK5");
    }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

      throw new ActivitiIllegalArgumentException("'html' or 'text' is required to be defined when using the mail activity");
    }
  }

  protected HtmlEmail createHtmlEmail(String text, String html) {
    HtmlEmail email = new HtmlEmail();
    try {
      email.setHtmlMsg(html);
      if (text != null) { // for email clients that don't support html
        email.setTextMsg(text);
      }
      return email;
    } catch (EmailException e) {
      throw new ActivitiException("Could not create HTML email", e);
    }
View Full Code Here

Examples of org.apache.commons.mail.HtmlEmail

  public static void sendHtmlMail(final String from, final String fromName, final String to, final String toName, final String cc, final String bcc, final String bounce, final String subject,
          final String htmlContent, final String textContent)
    throws EmailException {

    HtmlEmail mail = new HtmlEmail();

    setup(mail, to, toName, from, fromName, cc, bcc, bounce, subject);
    mail.setHtmlMsg(htmlContent);
    mail.setTextMsg(textContent);
    mail.send();

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.