Package sos.net

Examples of sos.net.SOSMimeMessage


    public boolean spooler_process() throws Exception {

      boolean expunge    = false; // delete marked messages
        Folder folder     = null;
        Message[] messages   = {};
        SOSMimeMessage sosMimeMessage = null;

        try {

            this.getLogger().debug3("Calling " + SOSClassUtil.getMethodName());

            receiver = new SOSMailReceiver(receiverHost, receiverPort, pop3_user,
                    pop3_password);

            receiver.setLogger(this.getLogger());

            receiver.connect(protocol);

            folder = receiver.openFolder("INBOX", receiver.READ_WRITE);

            // processed bounced emails selected??
            if (this.isHandleBouncedMessagesOnly())
                messages = folder.search(getBounceSerachTerm());
            else
                messages = folder.getMessages();

            getLogger().debug5("total found messages: " + messages.length);

            for (int i = 0; i < messages.length; i++) {
                sosMimeMessage = new SOSMimeMessage(messages[i], this
                        .getLogger());
                if (sosMimeMessage.isBounce()) {
                    handleBounceMessage(sosMimeMessage);
                }// if
            }// for
           
            this.getConnection().commit();
View Full Code Here


        for (;it.hasNext();) {
          sosMailAttachment = (SOSMailAttachment)it.next();
          // check if the attachment = message
            if (sosMailAttachment.getContentType().equalsIgnoreCase(
                    "message/rfc822")) {
                SOSMimeMessage originalMessage = sosMimeMessage
                        .getAttachedSosMimeMessage(receiver.getSession(),
                            sosMailAttachment.getContent());

                this
                        .setXSOSMailDeliveryCounterHeader(getXSOSMailDeliveryCounterHeader(originalMessage));

                this.getLogger().info("....originally message attributes:");
                this.getLogger().info(
                        "....message id [" + originalMessage.getMessageId()
                                + "]");
                this.getLogger().info(
                        "....from [" + originalMessage.getFromAddress() + "]");
                this
                        .getLogger()
                        .info(
                                "....sent date ["
                                        + originalMessage
                                                .getSentDateAsString("yyyy-MM-dd HH:mm:ss")
                                        + "]");
               
                // .. get the mails.id of the originalMessage.getMessageId if exists
                setMailId(getMailId(originalMessage.getMessageId()));
               
                if(SOSString.isEmpty(getMailId())) // .. skip if no entry available
                  continue;
               
                // .. then update the "MAILS" table
                this.updateTableMails(originalMessage.getMessageId());
               
                if (!SOSString.isEmpty(getXSOSMailDeliveryCounterHeader())) {
                    this
                            .getLogger()
                            .info(
                                    "...current "
                                            + JobSchedulerMailBounceHandler.X_SOSMAIL_DELIVERY_COUNTER_HEADER
                                            + " ["
                                            + this
                                                    .getXSOSMailDeliveryCounterHeader()
                                            + "]");
                }//if

                bouncedMailAction = this
                        .getPatternAction(sosMimeMessage);

                this.getLogger().info(
                        "..available pattern action for this bounce ["
                                + bouncedMailAction + "]");

               
                // handle action...
                if (bouncedMailAction.equalsIgnoreCase("drop")) { // delete
                                                                        // bounced
                                                                        // message
                    this.getLogger().info(
                            "..Message with ID ["
                                    + sosMimeMessage.getMessageId()
                                    + "] is marked for delete.");
                    sosMimeMessage.deleteMessage();
                    bouncedMailStatus = BounceMailStatus.CANCELLED;
                } else if (bouncedMailAction.equalsIgnoreCase("store")) {
                    String fileName = getLogDirectory() + File.separator
                            + sosMimeMessage.getMessageId();
                    sosMimeMessage.dumpMessageToFile(fileName, true,false);
                    bouncedMailStatus = BounceMailStatus.REQUESTED;                   
                   
                } else if (bouncedMailAction.equalsIgnoreCase("retry")) {
                    // check if retry sending allowed
                    if (isRetrySendingAllowed(originalMessage.getMessageId())) {

                        setRetryInterval(getRetryInterval(originalMessage));
                        // incr. the X-Header if exists otherwise add a new one
                        int currentHeaderValue;
                        if ( (currentHeaderValue=originalMessage.incrementHeader(JobSchedulerMailBounceHandler.X_SOSMAIL_DELIVERY_COUNTER_HEADER)) == -1) {
                          currentHeaderValue = 1;
                          originalMessage.setHeader(JobSchedulerMailBounceHandler.X_SOSMAIL_DELIVERY_COUNTER_HEADER,"1");
                          getLogger().debug5(".. [" + JobSchedulerMailBounceHandler.X_SOSMAIL_DELIVERY_COUNTER_HEADER + "] set.");
                        }
                        getLogger().debug5("..current value of \"" + JobSchedulerMailBounceHandler.X_SOSMAIL_DELIVERY_COUNTER_HEADER + "\" [" +currentHeaderValue + "]");
                       
                        getLogger().debug5("..query directory [" + bounceDirectory + " ] set.");
                        originalMessage.setQueueDir(bounceDirectory);
                        originalMessage.dumpMessageToFile(true,false);
                        this.getLogger().debug5("..currently dumped message [" +originalMessage.getDumpedFileName() + "]" );
                       
                        if (!orderRetrySend(originalMessage))
                          continue;
                    }
                    bouncedMailStatus = BounceMailStatus.DELIVERED;
View Full Code Here

      if (messages == null) {
        return false;
      }
      if (!messages.isEmpty()) {
        Iterator messageIterator = messages.iterator();
        SOSMimeMessage newestMail = null;
        while (messageIterator.hasNext()) {
          SOSMimeMessage message = (SOSMimeMessage) messageIterator.next();
          spooler_log.info(message.getSubject());
          Date messageDate = message.getSentDate();
          if (newestMail == null || messageDate.after(newestMail.getSentDate()))
            newestMail = message;
          performAction(message);
        }
      }
View Full Code Here

        for (int i = 0; i < msgs2.length; i++) {
          if (mailUseSeen && msgs2[i].isSet(Flags.Flag.SEEN)) {
            sosLogger.info("message skipped, already seen: " + msgs2[i].getSubject());
            continue;
          }
          SOSMimeMessage message = new SOSMimeMessage(msgs2[i], sosLogger);
          // skip mails that do not match the subject pattern
          if (!mailSubjectPattern.equals("")) {
            Matcher subjectMatcher = subjectPattern.matcher(message.getSubject());
            if (!subjectMatcher.find()) {
              sosLogger.info("message skipped, subject does not match [" + mailSubjectPattern + "]: " + message.getSubject());
              continue;
            }
          }
          // skip mails whose body does not match the download link pattern
          if (!mailBodyPattern.equals("")) {
            Matcher bodyMatcher = bodyPattern.matcher(message.getPlainTextBody());
            if (!bodyMatcher.find()) {
              sosLogger.info("message skipped, no match found for  [" + mailBodyPattern + "]: " + message.getPlainTextBody());
              continue;
            }
          }
          messages.add(message);
        }
View Full Code Here

TOP

Related Classes of sos.net.SOSMimeMessage

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.