Package com.dotmarketing.util

Examples of com.dotmarketing.util.Mailer


    return sendEmailForMailingList(to, from, subject);
  }

  protected static boolean sendEmailForMailingList(String to, String from,
      String subject) {
    Mailer m = new Mailer();
    m.setToEmail(to);
    m.setFromEmail(from);
    m.setSubject(subject);
    return m.sendMessage();
  }
View Full Code Here


        message = writer.toString().trim();
      } catch (ResourceNotFoundException ex) {
        message = "<center><b>And error has ocurred loading de message's page<b></center>";
      }

      Mailer m = new Mailer();
      m.setToEmail(user.getEmailAddress());
      m.setSubject("Your " + host.getHostname() + " Password");
      m.setHTMLBody(message);
      m.setFromEmail(Config.getStringProperty("EMAIL_SYSTEM_ADDRESS"));
      return m.sendMessage();
    } catch (Exception e) {
      Logger.warn(EmailFactory.class, e.toString(), e);
      return false;
    }
View Full Code Here

        } catch (Exception e) {
          Logger.warn(EmailFactory.class, "sendForm: Couldn't save the email backup in " + Config.getStringProperty("EMAIL_BACKUPS"));
        }

        // send the mail out;
        Mailer m = new Mailer();
        m.setToEmail(to);
        m.setFromEmail(from);
        m.setFromName(fromName);
        m.setCc(cc);
        m.setBcc(bcc);
        m.setSubject(subject);

        if (html) {
          if(UtilMethods.isSet(emailBodies.get("emailHTMLBody")))
            m.setHTMLBody(emailBodies.get("emailHTMLBody"));
          else
            m.setHTMLBody(emailBodies.get("emailHTMLTableBody"));
        }
        m.setTextBody(emailBodies.get("emailPlainTextBody"));

        //Attaching files requested to be attached to the email
        if(attachFiles != null) {
          attachFiles = "," + attachFiles.replaceAll("\\s", "") + ",";
          for(Entry<String, Object> entry : parameters.entrySet()) {
            if(entry.getValue() instanceof File && attachFiles.indexOf("," + entry.getKey() + ",") > -1) {
              File f = (File)entry.getValue();
              m.addAttachment(f, entry.getKey() + "." + UtilMethods.getFileExtension(f.getName()));
            }
          }
        }

        if (m.sendMessage()) {

          // there is an auto reply, send it on
          if ((UtilMethods.isSet((String)getMapValue("autoReplyTemplate", parameters)) ||
              UtilMethods.isSet((String)getMapValue("autoReplyText", parameters)))
              && UtilMethods.isSet((String)getMapValue("autoReplySubject", parameters))
              && UtilMethods.isSet((String)getMapValue("autoReplyFrom", parameters))) {

            templatePath = (String) getMapValue("autoReplyTemplate", parameters);

            if(UtilMethods.isSet(templatePath)) {
              try {
                emailBodies = buildEmail(templatePath, host, orderedMap, prettyVariableNamesMap, filesLinks.toString(), ignoreString, user);
              } catch (Exception e) {
                Logger.error(EmailFactory.class, "sendForm: Couldn't build the auto reply email body text. Sending plain text.", e);
              }
            }

            m = new Mailer();
            String autoReplyTo = (String)(getMapValue("autoReplyTo", parameters) == null?getMapValue("from", parameters):getMapValue("autoReplyTo", parameters));
            m.setToEmail(UtilMethods.replace(autoReplyTo, "spamx", ""));
            m.setFromEmail(UtilMethods.replace((String)getMapValue("autoReplyFrom", parameters), "spamx", ""));
            m.setSubject((String)getMapValue("autoReplySubject", parameters));

            String autoReplyText = (String)getMapValue("autoReplyText", parameters);
            boolean autoReplyHtml = getMapValue("autoReplyHtml", parameters) != null?Parameter.getBooleanFromString((String)getMapValue("autoReplyHtml", parameters)):html;
            if (autoReplyText != null)
            {
              if(autoReplyHtml)
              {
                m.setHTMLBody((String)getMapValue("autoReplyText", parameters));
              } else {
                m.setTextBody((String)getMapValue("autoReplyText", parameters));
              }
            }
            else
            {
              if (autoReplyHtml)
              {
                if(UtilMethods.isSet(emailBodies.get("emailHTMLBody")))
                  m.setHTMLBody(emailBodies.get("emailHTMLBody"));
                else
                  m.setHTMLBody(emailBodies.get("emailHTMLTableBody"));
              }
              m.setTextBody(emailBodies.get("emailPlainTextBody"));
            }
            m.sendMessage();
          }
        } else {
          if(formBean != null){
            try {
              HibernateUtil.delete(formBean);
View Full Code Here

            "&token="+token+"&switchLocale="+locale.getLanguage()+"_"+locale.getCountry();
   
    String body = LanguageUtil.format(locale, "reset-password-email-body", url, false);
   
    try {
      Mailer m = new Mailer();
      m.setToEmail(emailAddress);
      m.setToName(user.getFullName());
      m.setSubject(LanguageUtil.get(locale, "reset-password-email-subject"));
      m.setHTMLBody(body.toString());
      m.setFromName(company.getName());
      m.setFromEmail(company.getEmailAddress());
      m.sendMessage();
    }
    catch (Exception ioe) {
      throw new SystemException(ioe);
    }
  }
View Full Code Here

  }

  public void sendEmail(CreateAccountForm form, HttpServletRequest request) throws NoSuchUserException, DotDataException, DotSecurityException, LanguageException
  {             
    Mailer mailer = new Mailer();       

    //### CREATE MAIL ###
    StringBuffer body = new StringBuffer();

    body.append("<table border=\"1\">");
    body.append("<tr><td align=\"center\"><b>FIELD</b></td><td align=\"center\"><b>VALUE</b></td></tr>");
    //email
    String email = (UtilMethods.isSet(form.getEmailAddress()) ? form.getEmailAddress() : "&nbsp;");       
    body.append("<tr><td valign=\"top\"><b>Email Address:</b></td><td>" + email + "</td></tr>");
    //first name
    String firstName = (UtilMethods.isSet(form.getFirstName()) ? form.getFirstName() : "&nbsp;");
    body.append("<tr><td valign=\"top\"><b>First Name:</b></td><td>" + firstName + "</td></tr>");                       
    //last name
    String lastName = (UtilMethods.isSet(form.getLastName()) ? form.getLastName() : "&nbsp;");
    body.append("<tr><td valign=\"top\"><b>Last Name:</b></td><td>" + lastName + "</td></tr>");
    //title
    //organization
    String organization = (UtilMethods.isSet(form.getOrganization()) ? form.getOrganization() : "&nbsp;");
    body.append("<tr><td valign=\"top\"><b>Organization:</b></td><td>" + organization + "</td></tr>");
    //URL
    String webSite = (UtilMethods.isSet(form.getWebsite()) ? form.getWebsite() : "&nbsp;");
    body.append("<tr><td valign=\"top\"><b>webSite:</b></td><td>" + webSite + "</td></tr>");
    //comments
    String comments = (UtilMethods.isSet(form.getComments()) ? form.getComments() : "&nbsp;");
    body.append("<tr><td valign=\"top\"><b>Comment:</b></td><td>" + comments + "</td></tr>");
    //end table
    body.append("</table>");

    String emailBody = body.toString();
    //### END CREATE MAIL ###
    Company company = PublicCompanyFactory.getDefaultCompany();
    User user = APILocator.getUserAPI().loadByUserByEmail(form.getEmailAddress(), APILocator.getUserAPI().getSystemUser(), false);

    String toEmail = request.getParameter("emailAddress");
    String subject = request.getParameter("subject");
    String fromName = request.getParameter("fromName");
    String fromEmail = request.getParameter("fromEmail");
    subject = LanguageUtil.get(user, "verification-email-account-created");

    toEmail = (UtilMethods.isSet(toEmail) ? toEmail : Config.getStringProperty("CREATE_ACCOUNT_MAIL_ADDRESS"));
    subject = (UtilMethods.isSet(subject) ? subject : Config.getStringProperty("CREATE_ACCOUNT_MAIL_SUBJECT"));   
    fromName = (UtilMethods.isSet(fromName) ? fromName : Config.getStringProperty("CREATE_ACCOUNT_MAIL_NAME"));
    fromEmail = (UtilMethods.isSet(fromEmail) ? fromEmail : Config.getStringProperty("CREATE_ACCOUNT_MAIL_RETURN_ADDRESS"));       
    fromName = (UtilMethods.isSet(fromName) ? fromName : company.getName());
    fromEmail = (UtilMethods.isSet(fromEmail) ? fromEmail : company.getEmailAddress());

    mailer.setToEmail(toEmail);
    mailer.setSubject(subject);
    mailer.setFromName(fromName);
    mailer.setFromEmail(fromEmail);
    mailer.setHTMLBody(emailBody);
    mailer.sendMessage();
  }
View Full Code Here

    //campaign.addChild(recipient);


    Campaign campaign = getCampaign();
    Communication comm = (Communication) InodeFactory.getChildOfClass(campaign, Communication.class);
    Mailer Mailer = new Mailer();

    //get subject and message
    String subject = comm.getEmailSubject();

    User tempUser = new User();
    try {
      BeanUtils.copyProperties(tempUser, subscriber);
    } catch (Exception e) {
    }
    tempUser.setFirstName(recipient.getName());
    subject = replaceTextVar(subject, recipient, tempUser, comm);

    Mailer.setRecipientId(recipient.getInode());
    Mailer.setFromName(replaceTextVar(comm.getFromName(), recipient, subscriber, comm));
    Logger.debug(DeliverCampaignThread.class, "comm.getFromName()="+comm.getFromName());
    Mailer.setFromEmail(replaceTextVar(comm.getFromEmail(), recipient, subscriber, comm));
    Logger.debug(DeliverCampaignThread.class, "comm.getFromEmail()="+comm.getFromEmail());
    Mailer.setToEmail(recipient.getEmail());

    if(UtilMethods.isSet(recipient.getLastname()))
      Mailer.setToName(recipient.getName()+" "+recipient.getLastname());
    else
      Mailer.setToName(recipient.getName());

    Mailer.setSubject(subject);

    String finalMessageStr = message.toString();

    Logger.debug(DeliverCampaignThread.class, "sendEmail: message = " + message);

    finalMessageStr = replaceTextVar(finalMessageStr, recipient, subscriber, comm);

    if (html) {
      //personalize
      Mailer.setHTMLBody(finalMessageStr);
      if (alternateTextMessage != null) {
        Mailer.setTextBody(alternateTextMessage);
      }
    }
    else {
      //personalize
      Mailer.setTextBody(finalMessageStr);
    }

    boolean sent = Mailer.sendMessage();
    if (!sent) {

      recipient.setLastResult(500);
      recipient.setLastMessage(Mailer.getErrorMessage());
    }
    else{
      recipient.setLastResult(200);
      recipient.setLastMessage("Mail Sent");
View Full Code Here

        isHTML = true;
      } else {
        emailText = VelocityUtil.eval(emailText, ctx);
      }
      for(String x: email){
        Mailer mail = new Mailer();
        mail.setFromEmail(processor.getUser().getEmailAddress());
        mail.setFromName(processor.getUser().getFullName());
        mail.setToEmail(x);
        mail.setSubject(VelocityUtil.eval(subject, ctx));
        if (isHTML) {
          mail.setHTMLAndTextBody(emailText);
        } else {
          mail.setTextBody(emailText);
        }
        mail.sendMessage();
      }
    } catch (Exception e) {
      throw new DotWorkflowException("Exception ocurred trying to deliver emails for workflow " + e.getMessage());
    }
View Full Code Here

      String emails = emailsSB.toString();
      emails = emails.substring(0,emails.lastIndexOf(","));
      File attachment = saveExcelWebFormsToFS(reportType,initialDate,finalDate);

      //Create the Emails and sent it
      Mailer mailer = new Mailer();   
      mailer.setToEmail(emails);
      mailer.setSubject(subject);
      mailer.setFromEmail(fromEmail);
      mailer.setFromName(fromName);

      mailer.addAttachment(attachment);
      mailer.sendMessage();
    }
    catch(Exception ex)
    {
      String message = ex.toString();
      Logger.debug(WebFormFactory.class, message);
View Full Code Here

                isHTML = true;
            } else {
                emailText = VelocityUtil.eval(emailText, ctx);
            }
            for(String x: email){
                Mailer mail = new Mailer();
                mail.setFromEmail(emailFrom);
                mail.setFromName(emailFromFullName);
                mail.setToEmail(x);
                mail.setSubject(VelocityUtil.eval(subject, ctx));
                if (isHTML) {
                    mail.setHTMLAndTextBody(emailText);
                } else {
                    mail.setTextBody(emailText);
                }
                mail.sendMessage();
            }
        } catch (Exception e) {
            throw new DotWorkflowException("Exception ocurred trying to deliver emails for workflow " + e.getMessage());
        }
View Full Code Here

TOP

Related Classes of com.dotmarketing.util.Mailer

Copyright © 2018 www.massapicom. 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.