Package sos.net

Examples of sos.net.SOSMail


              } catch (Exception e) {
                throw new Exception("error occurred checking parameters: " + e.getMessage());
              }
             
              try { // to process order
                SOSMail sosMail = new SOSMail(host);
               
                sosMail.setPort(Integer.toString(port));
                sosMail.setQueueDir(queueDir);
                sosMail.setFrom(from);
                sosMail.setContentType(contentType);
                sosMail.setEncoding(encoding);
               
                String recipientsTo[] = to.split(",");
                for(int i=0; i<recipientsTo.length; i++) {
                  if (i==0) sosMail.setReplyTo(recipientsTo[i].trim());
                  sosMail.addRecipient(recipientsTo[i].trim());
                }
               
                String recipientsCC[] = cc.split(",");
                for(int i=0; i<recipientsCC.length; i++) {
                  sosMail.addCC(recipientsCC[i].trim());
                }
               
                String recipientsBCC[] = bcc.split(",");
                for(int i=0; i<recipientsBCC.length; i++) {
                  sosMail.addBCC(recipientsBCC[i].trim());
                }
               
                sosMail.setSubject(subject);
                sosMail.setBody(body);
               
                sosMail.setAttachmentCharset(attachmentCharset);
                sosMail.setAttachmentEncoding(attachmentEncoding);
                sosMail.setAttachmentContentType(attachmentContentType);
               
                for(int i=0; i<attachments.length; i++) {
                  File attachmentFile = new File(attachments[i]);
                  SOSMailAttachment attachment = new SOSMailAttachment(sosMail, attachmentFile);
                  attachment.setCharset(attachmentCharset);
                  attachment.setEncoding(attachmentEncoding);
                  attachment.setContentType(attachmentContentType);
                  sosMail.addAttachment(attachment);
                }
               
                sosMail.setSOSLogger(this.getLogger());
                this.getLogger().info("sending mail: \n" + sosMail.dumpMessageAsString());
               
                if (!sosMail.send()){
                  this.getLogger().warn("mail server is unavailable, mail for recipient [" + to + "] is queued in local directory [" + sosMail.getQueueDir() + "]:" + sosMail.getLastError());
                }

                    if ( cleanupAttachment ) {
                        for(int i=0; i<attachments.length; i++) {
                          File attachmentFile = new File(attachments[i]);
                          if ( attachmentFile.exists() && attachmentFile.canWrite() ) {
                            SOSFile.deleteFile( attachmentFile );
                          }
                        }
                    }
               
                sosMail.clearRecipients();
               
              } catch (Exception e) {
                throw new Exception(e.getMessage());
              }
             
View Full Code Here


     * @throws Exception
     */
    public void sendMail(String recipient, String recipientCC, String recipientBCC, String subject, String body) throws Exception {
       
        try {
            SOSMail sosMail = new SOSMail(spooler_log.mail().smtp());

            sosMail.setQueueDir(spooler_log.mail().queue_dir());
            sosMail.setFrom(spooler_log.mail().from());
            sosMail.setContentType("text/plain");
            sosMail.setEncoding("Base64");
               
            String recipients[] = recipient.split(",");
            for(int i=0; i<recipients.length; i++) {
                if (i==0) sosMail.setReplyTo(recipients[i].trim());
                sosMail.addRecipient(recipients[i].trim());
            }

            String recipientsCC[] = recipientCC.split(",");
            for(int i=0; i<recipientsCC.length; i++) {
                sosMail.addCC(recipientsCC[i].trim());
            }

            String recipientsBCC[] = recipientBCC.split(",");
            for(int i=0; i<recipientsBCC.length; i++) {
                sosMail.addBCC(recipientsBCC[i].trim());
            }

            sosMail.setSubject(subject);
            sosMail.setBody(body);
            sosMail.setSOSLogger(this.getLogger());
       
            this.getLogger().info("sending mail: \n" + sosMail.dumpMessageAsString());
           
            if (!sosMail.send()){
                this.getLogger().warn("mail server is unavailable, mail for recipient [" + recipient + "] is queued in local directory [" + sosMail.getQueueDir() + "]:" + sosMail.getLastError());
            }
       
            sosMail.clearRecipients();
        } catch (Exception e) {
            throw new Exception("error occurred in monitor sending mai: " + e.getMessage());
        }
    }
View Full Code Here

              } catch (Exception e) {
                throw new Exception("error occurred checking parameters: " + e.getMessage());
              }
             
              try { // to process order
                SOSMail sosMail = new SOSMail(host);
               
                sosMail.setPort(Integer.toString(port));
                sosMail.setQueueDir(queueDir);
                sosMail.setFrom(from);
                sosMail.setContentType(contentType);
                sosMail.setEncoding(encoding);
               
                String recipientsTo[] = to.split(",");
                for(int i=0; i<recipientsTo.length; i++) {
                  if (i==0) sosMail.setReplyTo(recipientsTo[i].trim());
                  sosMail.addRecipient(recipientsTo[i].trim());
                }
               
                String recipientsCC[] = cc.split(",");
                for(int i=0; i<recipientsCC.length; i++) {
                  sosMail.addCC(recipientsCC[i].trim());
                }
               
                String recipientsBCC[] = bcc.split(",");
                for(int i=0; i<recipientsBCC.length; i++) {
                  sosMail.addBCC(recipientsBCC[i].trim());
                }
               
                sosMail.setSubject(subject);
                sosMail.setBody(body);
               
                sosMail.setAttachmentCharset(attachmentCharset);
                sosMail.setAttachmentEncoding(attachmentEncoding);
                sosMail.setAttachmentContentType(attachmentContentType);
               
                for(int i=0; i<attachments.length; i++) {
                  File attachmentFile = new File(attachments[i]);
                  SOSMailAttachment attachment = new SOSMailAttachment(sosMail, attachmentFile);
                  attachment.setCharset(attachmentCharset);
                  attachment.setEncoding(attachmentEncoding);
                  attachment.setContentType(attachmentContentType);
                  sosMail.addAttachment(attachment);
                }
               
                sosMail.setSOSLogger(this.getLogger());
               
                this.getLogger().info("sending mail: \n" + sosMail.dumpMessageAsString());
               
                if (!sosMail.send()){
                  this.getLogger().warn("mail server is unavailable, mail for recipient [" + to + "] is queued in local directory [" + sosMail.getQueueDir() + "]:" + sosMail.getLastError());
                }

                        if ( cleanupAttachment ) {
                         
                            for(int i=0; i<attachments.length; i++) {
                              File attachmentFile = new File(attachments[i]);
                              if ( attachmentFile.exists() && attachmentFile.canWrite() ) {
                                SOSFile.deleteFile( attachmentFile );
                              }
                            }
                        }
               
                sosMail.clearRecipients();
               
              } catch (Exception e) {
                throw new Exception(e.getMessage());
              }
             
View Full Code Here

         spooler_log_warn("The  mail address for notification on automatic updates is missing");
       }else {
// ------------------------------------------------------
            String contentType = "text/plain";

           SOSMail sosMail = new SOSMail(spooler_log.mail().smtp());

           sosMail.setFrom(spooler_log.mail().from());
           sosMail.setContentType(contentType);

           sosMail.addRecipient(emailAddress);
           String subject = "New release for Job Scheduler available";
           sosMail.setSubject(subject);
           sosMail.setReplyTo(spooler_log.mail().from());

           String body = "A new release of the Job Scheduler is available.\nYour version is: "
               + schedulerUpdateAnswer.release
               + "\nThe new version is: "
               + schedulerUpdateAnswer.new_release;
           
           if (transferFile != null && schedulerUpdateAnswer.automatic_download.equals("1") || schedulerUpdateAnswer.automatic_download.equalsIgnoreCase("true")) {
             body += "\nThe update has been downloaded to: "  + transferFile.getAbsoluteFile();
           }
           sosMail.setBody(body);
           sosMail.send();
           }
          }
         } catch (Exception e) {
             spooler_log_warn("error sending mail to: " + emailAddress + " --> " + e.getMessage());
        }
View Full Code Here

      }
    }
    try{
      if (job.getConnection()==null){
        getLogger().debug7("Initializing SOSMail without database.");
        mail = new SOSMail(mailServer);
        getLogger().debug9("Setting mail sender: "+logMailFrom);
        mail.setFrom(logMailFrom);
        mail.setUser(mailUser);
        mail.setPassword(mailPassword);
        mail.setCharset("ISO-8859-1");   
        mail.setQueueDir(job.spooler_log.mail().queue_dir());
      }else if (sosMailSettings!=null && sosMailSettings.getSection()!=null && sosMailSettings.getSection().size()>0){       
        if (hasSOSMailOrder){
          getLogger().debug7("Initializing SOSMailOrder with Mail Settings");
          mail = new SOSMailOrder(sosMailSettings, job.getConnection());
        } else{
          getLogger().debug7("Initializing SOSMail with Mail Settings");
          mail = new SOSMail(sosMailSettings);
        }
      }else{
        if (hasSOSMailOrder){
          getLogger().debug7("Initializing SOSMailOrder without Mail Settings");
          mail = new SOSMailOrder(mailServer, job.getConnection());
        } else{
          getLogger().debug7("Initializing SOSMail without Mail Settings");
            mail = new SOSMail(mailServer);
        }
        getLogger().debug9("Setting mail sender: "+logMailFrom);
        mail.setFrom(logMailFrom);
        if (mailUser!=null){
          getLogger().debug9("Setting mail user: "+mailUser);
View Full Code Here

            if (messageFile.exists()) messageFile.delete();
            workFile.renameTo(messageFile);
           
            // populate mailer with settings
            if (this.sosMailSettings != null) {
                sosMail = new SOSMail( this.sosMailSettings );
            } else {
                sosMail = new SOSMail(spooler_log.mail().smtp());
            }

            if (this.getLogger() != null) sosMail.setSOSLogger(this.getLogger());

            // job scheduler sets mail host if no default was specified by settings
View Full Code Here

     * @throws Exception
     */
    public void sendMail(String recipient, String recipientCC, String recipientBCC, String subject, String body) throws Exception {
       
        try {
            SOSMail sosMail = new SOSMail(spooler_log.mail().smtp());

            sosMail.setQueueDir(spooler_log.mail().queue_dir());
            sosMail.setFrom(spooler_log.mail().from());
            sosMail.setContentType("text/plain");
            sosMail.setEncoding("Base64");
               
            String recipients[] = recipient.split(",");
            for(int i=0; i<recipients.length; i++) {
                if (i==0) sosMail.setReplyTo(recipients[i].trim());
                sosMail.addRecipient(recipients[i].trim());
            }

            String recipientsCC[] = recipientCC.split(",");
            for(int i=0; i<recipientsCC.length; i++) {
                sosMail.addCC(recipientsCC[i].trim());
            }

            String recipientsBCC[] = recipientBCC.split(",");
            for(int i=0; i<recipientsBCC.length; i++) {
                sosMail.addBCC(recipientsBCC[i].trim());
            }

            sosMail.setSubject(subject);
            sosMail.setBody(body);
            sosMail.setSOSLogger(this.getLogger());
       
            this.getLogger().info("sending mail: \n" + sosMail.dumpMessageAsString());
           
            if (!sosMail.send()){
                this.getLogger().warn("mail server is unavailable, mail for recipient [" + recipient + "] is queued in local directory [" + sosMail.getQueueDir() + "]:" + sosMail.getLastError());
            }
       
            sosMail.clearRecipients();
        } catch (Exception e) {
            throw new Exception("error occurred in monitor sending mai: " + e.getMessage());
        }
    }
View Full Code Here

              } catch (Exception e) {
                throw new Exception("error occurred checking parameters: " + e.getMessage());
              }
             
              try { // to process order
                SOSMail sosMail;
                Properties mailSection = null;
                if (this.getConnectionSettings()!=null){
                  try{
                    mailSection = this.getConnectionSettings().getSection("email", "mail_server");
                    if (mailSection.size()<1) mailSection = null;
                  } catch(Exception e){
                    getLogger().debug6("No database settings found, using defaults from factory.ini");
                  }
                }
                if (mailSection!=null){
                  // use defaults from database settings
                  sosMail = new SOSMail(getConnectionSettings());
                  if (hostChanged) sosMail.setHost(host);
                  if (queueDirChanged) sosMail.setQueueDir(queueDir);
                  if (fromChanged) sosMail.setFrom(from);
                }else {
                  // use defaults from Scheduler configuration
                  sosMail = new SOSMail(host);
                  sosMail.setQueueDir(queueDir);
                  sosMail.setFrom(from);
                  SOSSettings smtpSettings = new SOSProfileSettings(spooler.ini_path());
                  Properties smtpProperties = smtpSettings.getSection("smtp");
                  if (!smtpProperties.isEmpty()) {
                            if (smtpProperties.getProperty("mail.smtp.user") != null && smtpProperties.getProperty("mail.smtp.user").length() > 0) {
                                sosMail.setUser(smtpProperties.getProperty("mail.smtp.user"));
                            }
                            if (smtpProperties.getProperty("mail.smtp.password") != null && smtpProperties.getProperty("mail.smtp.password").length() > 0) {
                                sosMail.setPassword(smtpProperties.getProperty("mail.smtp.password"));
                            }
                        }                 
                }
               
                if (portChanged) sosMail.setPort(Integer.toString(port));
                if (smtpUser.length()>0) sosMail.setUser(smtpUser);
                if (smtpPass.length()>0) sosMail.setPassword(smtpPass);
               
                // set values only if these are set by params, else use defaults from SOSMail
                if (contentType.length()>0) sosMail.setContentType(contentType);
                if (encoding.length()>0) sosMail.setEncoding(encoding);
               
                if (attachmentCharset.length()>0) sosMail.setAttachmentCharset(attachmentCharset);
                if (attachmentEncoding.length()>0)sosMail.setAttachmentEncoding(attachmentEncoding);
                if (attachmentContentType.length()>0) sosMail.setAttachmentContentType(attachmentContentType);
               
                if (fromName.length()>0) sosMail.setFromName(fromName);
               
                String recipientsTo[] = to.split(";|,");
                for(int i=0; i<recipientsTo.length; i++) {
                  if (i==0) sosMail.setReplyTo(recipientsTo[i].trim());
                  sosMail.addRecipient(recipientsTo[i].trim());
                }
                if (replyTo.length()>0) sosMail.setReplyTo(replyTo);               
                sosMail.addCC(cc);
                sosMail.addBCC(bcc);
                               
                sosMail.setSubject(subject);
                sosMail.setBody(body);
                
                for(int i=0; i<attachments.length; i++) {
                  File attachmentFile = new File(attachments[i]);
                  SOSMailAttachment attachment = new SOSMailAttachment(sosMail, attachmentFile);
                  attachment.setCharset(sosMail.getAttachmentCharset());
                  attachment.setEncoding(sosMail.getAttachmentEncoding());
                  attachment.setContentType(sosMail.getAttachmentContentType());
                  sosMail.addAttachment(attachment);
                }
               
                sosMail.setSOSLogger(this.getLogger());
               
                this.getLogger().info("sending mail: \n" + sosMail.dumpMessageAsString());
               
                if (!sosMail.send()){
                  this.getLogger().warn("mail server is unavailable, mail for recipient [" + to + "] is queued in local directory [" + sosMail.getQueueDir() + "]:" + sosMail.getLastError());
                }

                        if ( cleanupAttachment ) {
                         
                            for(int i=0; i<attachments.length; i++) {
                              File attachmentFile = new File(attachments[i]);
                              if ( attachmentFile.exists() && attachmentFile.canWrite() ) {
                                SOSFile.deleteFile( attachmentFile );
                              }
                            }
                        }
               
                sosMail.clearRecipients();
               
              } catch (Exception e) {
                throw new Exception(e.getMessage());
              }
             
View Full Code Here

    String readSettings = params.value("read_mail_settings");
    if (readSettings!=null && (readSettings.equalsIgnoreCase("yes") ||
        readSettings.equalsIgnoreCase("1") ||
        readSettings.equalsIgnoreCase("true")) ){
      if (job.getConnectionSettings()!=null && job.getConnectionSettings().getSection("email", "mail_server").size()>0){
        sosMail = new SOSMail(job.getConnectionSettings());       
        sosMail.setSOSLogger(logger);
      } else{
        throw new Exception("Mail Settings could not be found.");
      }
    } else{
View Full Code Here

    readParams(params);
  }
 
  private void init(sos.spooler.Log spooler_log) throws Exception{
    try{
      sosMail = new SOSMail(spooler_log.mail().smtp());
      if (logger==null) logger = new SOSSchedulerLogger(spooler_log);
      sosMail.setSOSLogger(logger);
      sosMail.setQueueDir(spooler_log.mail().queue_dir());
      sosMail.setFrom(spooler_log.mail().from());
      sosMail.addRecipient(spooler_log.mail().to());
View Full Code Here

TOP

Related Classes of sos.net.SOSMail

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.