Examples of LMTPMultiResponse


Examples of org.apache.james.protocols.lmtp.LMTPMultiResponse

      for (MailAddress address : env.getRecipients()) {
        replies.put(address, DeliveryReturnCode.TEMPORARY_FAILURE);
      }
    }

    LMTPMultiResponse lmtpResponse = null;
    for (MailAddress address : replies.keySet())
    {
      DeliveryReturnCode code = replies.get(address);
      SMTPResponse response;

      switch (code) {
      case OK:
        response = new SMTPResponse(SMTPRetCode.MAIL_OK,
            DSNStatus.getStatus(DSNStatus.SUCCESS, DSNStatus.UNDEFINED_STATUS)
            + " Ok");
        break;
      case NO_SUCH_USER:
        response = new SMTPResponse(SMTPRetCode.MAILBOX_PERM_UNAVAILABLE,
            DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.ADDRESS_MAILBOX)
            + " Unknown user " + address.toString());
        break;
      case OVER_QUOTA:
        response = new SMTPResponse(SMTPRetCode.QUOTA_EXCEEDED,
            DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.MAILBOX_FULL)
            + " User over quota");
        break;
      case PERMANENT_FAILURE:
        response = new SMTPResponse(SMTPRetCode.TRANSACTION_FAILED,
            DSNStatus.getStatus(DSNStatus.PERMANENT, DSNStatus.SYSTEM_OTHER)
            + " Unable to deliver message");
        break;
      case TEMPORARY_FAILURE:
        response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR,
            DSNStatus.getStatus(DSNStatus.TRANSIENT, DSNStatus.SYSTEM_OTHER)
            + " Unable to process request");
        break;
      default:
        response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR,
            DSNStatus.getStatus(DSNStatus.TRANSIENT, DSNStatus.SYSTEM_OTHER)
            + " Unable to process request");
        break;
      }

      if (lmtpResponse == null) {
        lmtpResponse = new LMTPMultiResponse(response);
      } else {
        lmtpResponse.addResponse(response);
      }

    }

    return lmtpResponse;
View Full Code Here

Examples of org.apache.james.protocols.lmtp.LMTPMultiResponse

    private final List<DeliverToRecipientHook> handlers = new ArrayList<DeliverToRecipientHook>();

   
    @Override
    protected Response processExtensions(SMTPSession session, MailEnvelopeImpl mail) {
        LMTPMultiResponse mResponse = null;

        Iterator<MailAddress> recipients = mail.getRecipients().iterator();
       
        while (recipients.hasNext()) {
            MailAddress recipient = recipients.next();
            Response response = null;
            for (DeliverToRecipientHook handler: handlers) {
                response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(handler.deliver(session, recipient, mail));
                if (response != null) {
                    break;
                }
            }
            if (response == null) {
                // Add some default response for not handled responses
                response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR, DSNStatus.getStatus(DSNStatus.TRANSIENT, DSNStatus.UNDEFINED_STATUS) + "Temporary error deliver message to " + recipient);
            }
            if (mResponse == null) {
                mResponse = new LMTPMultiResponse(response);
            } else {
                mResponse.addResponse(response);
            }
        }
        return mResponse;
    }
View Full Code Here

Examples of org.apache.james.protocols.lmtp.LMTPMultiResponse

    private final List<DeliverToRecipientHook> handlers = new ArrayList<DeliverToRecipientHook>();


    @Override
    protected Response processExtensions(SMTPSession session, final Mail mail) {
        LMTPMultiResponse mResponse = null;

        // build a wrapper around the Mail
        final ReadOnlyMailEnvelope env = new ReadOnlyMailEnvelope(mail);

        for (org.apache.mailet.MailAddress recipient : mail.getRecipients()) {
            // TODO: the transformation code between MailAddress is purely to compile. No idea if it does what it's supposed
            MailAddress recipientAddress;
            try {
                recipientAddress = new MailAddress(recipient.getLocalPart(), recipient.getDomain());
            } catch (MailAddressException e) {
                throw new RuntimeException(e);
            }
            Response response = null;
            for (DeliverToRecipientHook handler : handlers) {
                response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(handler.deliver(session, recipientAddress, env));
                if (response != null) {
                    break;
                }
            }
            if (response == null) {
                // Add some default response for not handled responses
                response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR, DSNStatus.getStatus(DSNStatus.TRANSIENT, DSNStatus.UNDEFINED_STATUS) + "Temporary error deliver message to " + recipient);
            }
            if (mResponse == null) {
                mResponse = new LMTPMultiResponse(response);
            } else {
                mResponse.addResponse(response);
            }
        }
        return mResponse;
    }
View Full Code Here

Examples of org.apache.james.protocols.lmtp.LMTPMultiResponse

    private final List<DeliverToRecipientHook> handlers = new ArrayList<DeliverToRecipientHook>();

   
    @Override
    protected Response processExtensions(SMTPSession session, MailEnvelopeImpl mail) {
        LMTPMultiResponse mResponse = null;

        Iterator<MailAddress> recipients = mail.getRecipients().iterator();
       
        while (recipients.hasNext()) {
            MailAddress recipient = recipients.next();
            Response response = null;
            for (DeliverToRecipientHook handler: handlers) {
                response = AbstractHookableCmdHandler.calcDefaultSMTPResponse(handler.deliver(session, recipient, mail));
                if (response != null) {
                    break;
                }
            }
            if (response == null) {
                // Add some default response for not handled responses
                response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR, DSNStatus.getStatus(DSNStatus.TRANSIENT, DSNStatus.UNDEFINED_STATUS) + "Temporary error deliver message to " + recipient);
            }
            if (mResponse == null) {
                mResponse = new LMTPMultiResponse(response);
            } else {
                mResponse.addResponse(response);
            }
        }
        return mResponse;
    }
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.