account = Provisioning.getInstance().get(AccountBy.NAME, rcptEmail);
account = Provisioning.getInstance().get(AccountBy.name, rcptEmail);
    private void deliverMessageToLocalMailboxes(byte[] data, List<LmtpAddress> recipients, String envSender)    throws MessagingException, ServiceException {        boolean shared = recipients.size() > 1;        List<Integer> targetMailboxIds = new ArrayList<Integer>(recipients.size());        Map<LmtpAddress, RecipientDetail> rcptMap = new HashMap<LmtpAddress, RecipientDetail>(recipients.size());        try {            // Examine attachments indexing option for all recipients and            // prepare ParsedMessage versions needed.  Parsing is done before            // attempting delivery to any recipient.  Therefore, parse error            // will result in non-delivery to all recipients.            // ParsedMessage for users with attachments indexing            ParsedMessage pmAttachIndex = null;            // ParsedMessage for users without attachments indexing            ParsedMessage pmNoAttachIndex = null;            for (LmtpAddress recipient : recipients) {                String rcptEmail = recipient.getEmailAddress();                Account account = null;                Mailbox mbox = null;                boolean attachmentsIndexingEnabled = true;                try {                    account = Provisioning.getInstance().get(AccountBy.NAME, rcptEmail);                    if (account == null) {                        ZimbraLog.mailbox.warn("No account found delivering mail to " + rcptEmail);                        continue;                    }                    mbox = Mailbox.getMailboxByAccount(account);                    if (mbox == null) {                        ZimbraLog.mailbox.warn("No mailbox found delivering mail to " + rcptEmail);                        continue;                    }                    attachmentsIndexingEnabled = mbox.attachmentsIndexingEnabled();                } catch (ServiceException se) {                    if (se.isReceiversFault()) {                    	ZimbraLog.mailbox.info("Recoverable exception getting mailbox for " + rcptEmail, se);                    	boolean skip = true;                    	rcptMap.put(recipient, new RecipientDetail(null, null, null, skip));                    } else {                    	ZimbraLog.mailbox.warn("Unrecoverable exception getting mailbox for " + rcptEmail, se);                    }                    continue;                }                if (account != null && mbox != null) {                    ParsedMessage pm;                    if (attachmentsIndexingEnabled) {                        if (pmAttachIndex == null)                            pmAttachIndex = new ParsedMessage(data, true).analyze();                        pm = pmAttachIndex;                    } else {                        if (pmNoAttachIndex == null)                            pmNoAttachIndex = new ParsedMessage(data, false).analyze();                        pm = pmNoAttachIndex;                    }                    assert(pm != null);                    boolean skip;                    if (shared) {                        // Skip delivery to mailboxes in backup mode.                    	skip = !mbox.beginSharedDelivery();                    } else {                        // For non-shared delivery (i.e. only one recipient),                        // always deliver regardless of backup mode.                        skip = false;                    }                    rcptMap.put(recipient, new RecipientDetail(account, mbox, pm, skip));                    if (!skip)	                    targetMailboxIds.add(new Integer(mbox.getId()));                }            }            SharedDeliveryContext sharedDeliveryCtxt =            	new SharedDeliveryContext(shared, targetMailboxIds);            // We now know which addresses are valid and which ParsedMessage            // version each recipient needs.  Deliver!            try {                // Performance                if (ZimbraLog.perf.isDebugEnabled())                    ThreadLocalData.reset();                for (LmtpAddress recipient : recipients) {                    String rcptEmail = recipient.getEmailAddress();                    LmtpStatus status = LmtpStatus.TRYAGAIN;                    RecipientDetail rd = rcptMap.get(recipient);                    try {                        if (rd != null) {                            if (!rd.skip) {                                Account account = rd.account;                                Mailbox mbox = rd.mbox;                                ParsedMessage pm = rd.pm;                                Message msg = null;                                                                ZimbraLog.addAccountNameToContext(account.getName());                                if (dedupe(pm, mbox)) {                                    // message was already delivered to this mailbox                                    msg = null;                                } else if (!DebugConfig.disableFilter) {                                    msg = RuleManager.getInstance().applyRules(account, mbox, pm, pm.getRawData().length,                                                                               rcptEmail, sharedDeliveryCtxt);                                } else {                                    msg = mbox.addMessage(null, pm, Mailbox.ID_FOLDER_INBOX, false, Flag.FLAG_UNREAD, null,                                                          rcptEmail, sharedDeliveryCtxt);                                }                                if (msg != null) {                                    recordReceipt(pm, mbox);                                    notify(account, mbox, msg, rcptEmail, envSender, pm);                                }                                status = LmtpStatus.ACCEPT;                            } else {                                // Delivery to mailbox skipped.  Let MTA retry again later.                                // This case happens for shared delivery to a mailbox in                                // backup mode.                                mLog.info("try again for message " + rcptEmail + ": mailbox skipped");                                status = LmtpStatus.TRYAGAIN;                            }                        } else {                            // Account or mailbox not found.                            mLog.info("rejecting message " + rcptEmail + ": account or mailbox not found");                        	status = LmtpStatus.REJECT;                        }                    } catch (IOException ioe) {                        status = LmtpStatus.TRYAGAIN;                        mLog.info("try again for " + rcptEmail + ": exception occurred", ioe);                    } catch (ServiceException se) {                        if (se.getCode().equals(MailServiceException.QUOTA_EXCEEDED)) {                            mLog.info("rejecting message " + rcptEmail + ": overquota");                            status = LmtpStatus.OVERQUOTA;                        } else if (se.isReceiversFault()) {                            mLog.info("try again for message " + rcptEmail + ": exception occurred", se);                            status = LmtpStatus.TRYAGAIN;                        } else {                            mLog.info("rejecting message " + rcptEmail + ": exception occurred", se);                            status = LmtpStatus.REJECT;                        }                    } catch (Exception e) {                        status = LmtpStatus.TRYAGAIN;                        mLog.info("try again for message " + rcptEmail + ": exception occurred", e);                    } finally {                        ZimbraLog.clearContext();                        recipient.setDeliveryStatus(status);                        if (shared && rd != null && !rd.skip) {                            rd.mbox.endSharedDelivery();                            rd.skip = true;                        }                    }                }            } finally {                // Clean up blobs in incoming directory after delivery to all recipients.                if (shared) {                    Blob sharedBlob = sharedDeliveryCtxt.getBlob();                    if (sharedBlob != null) {                        try {                            StoreManager.getInstance().delete(sharedBlob);                        } catch (IOException e) {                            mLog.warn("Unable to delete temporary incoming blob after delivery: " + sharedBlob.toString(), e);                        }                    }                }            }        } finally {            // Take mailboxes out of shared delivery mode.            if (shared) {                for (RecipientDetail rd : rcptMap.values()) {                    if (!rd.skip && rd.mbox != null)                        rd.mbox.endSharedDelivery();                }            }        }    }