Package org.olat.core.util.mail

Examples of org.olat.core.util.mail.Emailer


    try {
            IdentityManager im = (IdentityManager)CoreSpringFactory.getBean("core.id.IdentityManager");
      Identity ident = im.findIdentityByName(username);
      //if null, user may crashed befor getting a valid session, try with guest user instead
      if (ident == null) ident = im.findIdentityByName("guest");
      Emailer emailer = new Emailer(ident, true);
      LogFile lf = new LogFile();
      Date d = new Date();
      SimpleDateFormat year = new SimpleDateFormat("yyyy");
      SimpleDateFormat month = new SimpleDateFormat("MM");
      SimpleDateFormat day = new SimpleDateFormat("dd");
      String errorNum = parseErrorNumber(errorNr);
      Collection logFileEntries = lf.getError(errorNum, day.format(d), month.format(d), year.format(d), false);
      StringBuilder out = new StringBuilder();
      if (logFileEntries != null) {
        for (Iterator iter = logFileEntries.iterator(); iter.hasNext();) {
          out.append((String) iter.next());
        }
      }
      emailer.sendEmail(WebappHelper.getMailConfig("mailSupport"), "Feedback from Error Nr.: " + errorNr, request.getParameter("textarea")
          + "\n------------------------------------------\n\n --- from user: "+username+" ---" + out.toString());
    } catch (AddressException e) {
      // error in recipient email address(es)
      handleException(request, e);
      return;
View Full Code Here


   */
  public void event(UserRequest ureq, Component source, Event event) {
    if (source == cntctForm) {
      if (event == Form.EVNT_VALIDATION_OK) {
        boolean useInstitutionalEmail = false;
        Emailer emailer = new Emailer(emailFrom, useInstitutionalEmail);
        //
        boolean success = false;
        try {
          if(cntctForm.getCheckBoxElement("tcpfrom").isChecked()) {
            ContactList contactList = new ContactList(translate("contact.list.sender"));
            contactList.add(emailFrom);                                            
             cntctForm.addEmailTo(contactList);
          }
          success = emailer.sendEmail(cntctForm.getEmailToContactLists(), cntctForm.getSubject(), cntctForm.getBody());
        } catch (AddressException e) {
          //error in recipient email address(es)
          handleAddressException(success);
          //no return here, depending on boolean success there are
          //events to fire
View Full Code Here

    cl.add(WebappHelper.getMailConfig("mailSupport"));
    cl.add(ureq.getIdentity());
    List<ContactList> lstAddrTO = new ArrayList<ContactList>();
    lstAddrTO.add(cl);
   
    Emailer mailer = new Emailer(ureq.getLocale());
    try {
      mailer.sendEmail(lstAddrTO, subject, body);
    } catch (AddressException e) {
      Tracing.createLoggerFor(BulkDeleteController.class).error("Notificatoin mail for bulk deletion could not be sent");
    } catch (MessagingException e) {
      Tracing.createLoggerFor(BulkDeleteController.class).error("Notificatoin mail for bulk deletion could not be sent");
    }
View Full Code Here

    String ip = ureq.getHttpReq().getRemoteAddr();
    String today = DateFormat.getDateInstance(DateFormat.LONG, ureq.getLocale()).format(new Date());
    // mailer configuration
    String serverpath = Settings.getServerContextPathURI();
    String servername = ureq.getHttpReq().getServerName();
    Emailer mailer = new Emailer(ureq.getLocale());
    Tracing.createLoggerFor(ProfileAndHomePageEditController.class).debug("this servername is " + servername + " and serverpath is " + serverpath);
    // load or create temporary key
    HashMap<String, String> mailMap = new HashMap<String, String>();
    mailMap.put("currentEMail", currentEmail);
    mailMap.put("changedEMail", changedEmail);
   
    XStream xml = new XStream();
    String serMailMap = xml.toXML(mailMap);
   
    TemporaryKey tk = loadCleanTemporaryKey(serMailMap);       
    if (tk == null) {
      tk = rm.createTemporaryKeyByEmail(serMailMap, ip, RegistrationManager.EMAIL_CHANGE);
    } else {
      rm.deleteTemporaryKeyWithId(tk.getRegistrationKey());
      tk = rm.createTemporaryKeyByEmail(serMailMap, ip, RegistrationManager.EMAIL_CHANGE);
    }
   
    // create date, time string
    Calendar cal = Calendar.getInstance();
    cal.setTime(tk.getCreationDate());
    cal.add(Calendar.DAY_OF_WEEK, ChangeEMailController.TIME_OUT);
    String time = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, ureq.getLocale()).format(cal.getTime());
    // create body and subject for email
    body = this.translator.translate("email.change.body", new String[] { serverpath + "/dmz/emchange/index.html?key=" + tk.getRegistrationKey() + "&lang=" + ureq.getLocale().getLanguage(), time })
        + SEPARATOR + this.translator.translate("email.change.wherefrom", new String[] { serverpath, today, ip });
    subject = translate("email.change.subject");
    // send email
    try {
      boolean isMailSent = mailer.sendEmail(changedEmail, subject, body);
      if (isMailSent) {
        tk.setMailSent(true);
        // set key
        User user = this.identityToModify.getUser();
        user.setProperty("emchangeKey", tk.getRegistrationKey());
View Full Code Here

    if (locale == null) {
      locale = I18nManager.getInstance().getCurrentThreadLocale();
    }
    Translator translator = new PackageTranslator(this.getClass().getPackage().getName(), locale);
   
    Emailer emailer = new Emailer(locale);
    String subject = translator.translate(emailI18nSubkey+".subject");
    String body = translator.translate(emailI18nSubkey+".body");
    try {
      emailer.sendEmail(email, subject, body);
    } catch (AddressException e) {
      log_.error("Error sending information email to user that file was saved successfully.", e);
    } catch (SendFailedException e) {
      log_.error("Error sending information email to user that file was saved successfully.", e);
    } catch (MessagingException e) {
View Full Code Here

        User user = UserManager.getInstance().findUserByEmail(email);
        // get remote address
        String ip = ureq.getHttpReq().getRemoteAddr();
        String body = null;
        String today = DateFormat.getDateInstance(DateFormat.LONG, ureq.getLocale()).format(new Date());
        Emailer mailer = new Emailer(ureq.getLocale());
        //TODO eMail Vorlagen
        String serverpath = Settings.getServerContextPathURI();
        boolean isMailSent = false;
        if (user == null) {
          TemporaryKey tk = rm.loadTemporaryKeyByEmail(email);
          if (tk == null) tk = rm.createTemporaryKeyByEmail(email, ip, rm.REGISTRATION);
          myContent.contextPut("regKey", tk.getRegistrationKey());
          body = getTranslator().translate("reg.body",
              new String[] { serverpath, tk.getRegistrationKey(), I18nManager.getInstance().getLocaleKey(ureq.getLocale()) })
              + SEPARATOR
              + getTranslator().translate("reg.wherefrom", new String [] { serverpath, today, ip });
          try {
            if (mailer.sendEmail(email, translate("reg.subject"), body)) isMailSent = true;
          } catch (Exception e) {
            // nothing to do, emailSent flag is false, errors will be reported to user
          }
        } else {
          // a user exists, this is an error in the registration page
          // send email
          Identity identity = UserManager.getInstance().findIdentityByEmail(email);
          body = translate("login.body", identity.getName()) + SEPARATOR
              + getTranslator().translate("reg.wherefrom", new String[] { serverpath, today, ip });
          try {
            isMailSent = mailer.sendEmail(email, translate("login.subject"), body);
          } catch (Exception e) {
            // nothing to do, emailSent flag is false, errors will be reported to user
          }
        }
        if (isMailSent) {
View Full Code Here

TOP

Related Classes of org.olat.core.util.mail.Emailer

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.