⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractredirect.java

📁 java 开发的邮件服务器平台。支持以下协议。 协议可以修改为自己的专门标识
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * @return {@link #getInLineType()}     */    protected int getInLineType(Mail originalMail) throws MessagingException {        int inLineType = (isStatic()) ? this.inLineType : getInLineType();        return inLineType;    }    /** Gets the <CODE>attachment</CODE> property.     * May return one of the following values to indicate how to attach the original message     * to the new message:     * <ul>     *    <li><CODE>BODY</CODE> : original message body is attached as plain text to the new message</li>     *    <li><CODE>HEADS</CODE> : original message headers are attached as plain text to the new message</li>     *    <li><CODE>ALL</CODE> : original is attached as plain text with all headers</li>     *    <li><CODE>MESSAGE</CODE> : original message is attached as type message/rfc822, a complete mail message.</li>     *    <li><CODE>NONE</CODE> : original is not attached</li>     * </ul>     * Is a "getX()" method.     *     * @return the <CODE>attachment</CODE> init parameter, or <CODE>NONE</CODE> if missing     */    protected int getAttachmentType() throws MessagingException {        if(getInitParameter("attachment") == null) {            return NONE;        } else {            return getTypeCode(getInitParameter("attachment"));        }    }    /**     * Gets the <CODE>attachment</CODE> property,     * built dynamically using the original Mail object.     * Is a "getX(Mail)" method.     *     * @return {@link #getAttachmentType()}     */    protected int getAttachmentType(Mail originalMail) throws MessagingException {        int attachmentType = (isStatic()) ? this.attachmentType : getAttachmentType();        return attachmentType;    }    /**     * Gets the <CODE>message</CODE> property.     * Returns a message to which the original message can be attached/appended     * to build the new message.     * Is a "getX()" method.     *     * @return the <CODE>message</CODE> init parameter or an empty string if missing     */    protected String getMessage() throws MessagingException {        if(getInitParameter("message") == null) {            return "";        } else {            return getInitParameter("message");        }    }    /**     * Gets the <CODE>message</CODE> property,     * built dynamically using the original Mail object.     * Is a "getX(Mail)" method.     *     * @return {@link #getMessage()}     */    protected String getMessage(Mail originalMail) throws MessagingException {        String messageText = (isStatic()) ? this.messageText : getMessage();        return messageText;    }    /**     * Gets the <CODE>recipients</CODE> property.     * Returns the collection of recipients of the new message,     * or null if no change is requested.     * Is a "getX()" method.     *     * @return the <CODE>recipients</CODE> init parameter     * or the postmaster address     * or <CODE>SpecialAddress.SENDER</CODE>     * or <CODE>SpecialAddress.FROM</CODE>     * or <CODE>SpecialAddress.REPLY_TO</CODE>     * or <CODE>SpecialAddress.REVERSE_PATH</CODE>     * or <CODE>SpecialAddress.UNALTERED</CODE>     * or <CODE>SpecialAddress.RECIPIENTS</CODE>     * or <CODE>null</CODE> if missing     */    protected Collection getRecipients() throws MessagingException {        Collection newRecipients = new HashSet();        String addressList = getInitParameter("recipients");                // if nothing was specified, return <CODE>null</CODE> meaning no change        if (addressList == null) {            return null;        }        try {            InternetAddress[] iaarray = InternetAddress.parse(addressList, false);            for (int i = 0; i < iaarray.length; i++) {                String addressString = iaarray[i].getAddress();                MailAddress specialAddress = getSpecialAddress(addressString,                new String[] {"postmaster", "sender", "from", "replyTo", "reversePath", "unaltered", "recipients", "to", "null"});                if (specialAddress != null) {                    newRecipients.add(specialAddress);                } else {                    newRecipients.add(new MailAddress(iaarray[i]));                }            }        } catch (Exception e) {            throw new MessagingException("Exception thrown in getRecipients() parsing: " + addressList, e);        }        if (newRecipients.size() == 0) {            throw new MessagingException("Failed to initialize \"recipients\" list; empty <recipients> init parameter found.");        }        return newRecipients;    }    /**     * Gets the <CODE>recipients</CODE> property,     * built dynamically using the original Mail object.     * Is a "getX(Mail)" method.     *     * @return {@link #replaceMailAddresses} on {@link #getRecipients()},     */    protected Collection getRecipients(Mail originalMail) throws MessagingException {        Collection recipients = (isStatic()) ? this.recipients : getRecipients();        if (recipients != null) {            if (recipients.size() == 1 && (recipients.contains(SpecialAddress.UNALTERED) || recipients.contains(SpecialAddress.RECIPIENTS))) {                recipients = null;            } else {                recipients = replaceMailAddresses(originalMail, recipients);            }        }        return recipients;    }    /**     * Sets the recipients of <I>newMail</I> to <I>recipients</I>.     * If the requested value is null does nothing.     * Is a "setX(Mail, Tx, Mail)" method.     */    protected void setRecipients(Mail newMail, Collection recipients, Mail originalMail) throws MessagingException {        if (recipients != null) {            ((MailImpl) newMail).setRecipients(recipients);            if (isDebug) {                log("recipients set to: " + arrayToString(recipients.toArray()));            }        }    }    /**     * Gets the <CODE>to</CODE> property.     * Returns the "To:" recipients of the new message.     * or null if no change is requested.     * Is a "getX()" method.     *     * @return the <CODE>to</CODE> init parameter     * or the postmaster address     * or <CODE>SpecialAddress.SENDER</CODE>     * or <CODE>SpecialAddress.REVERSE_PATH</CODE>     * or <CODE>SpecialAddress.FROM</CODE>     * or <CODE>SpecialAddress.REPLY_TO</CODE>     * or <CODE>SpecialAddress.UNALTERED</CODE>     * or <CODE>SpecialAddress.TO</CODE>     * or <CODE>null</CODE> if missing     */    protected InternetAddress[] getTo() throws MessagingException {        InternetAddress[] iaarray = null;        String addressList = getInitParameter("to");                // if nothing was specified, return null meaning no change        if (addressList == null) {            return null;        }        try {            iaarray = InternetAddress.parse(addressList, false);            for(int i = 0; i < iaarray.length; ++i) {                String addressString = iaarray[i].getAddress();                MailAddress specialAddress = getSpecialAddress(addressString,                                                new String[] {"postmaster", "sender", "from", "replyTo", "reversePath", "unaltered", "recipients", "to", "null"});                if (specialAddress != null) {                    iaarray[i] = specialAddress.toInternetAddress();                }            }        } catch (Exception e) {            throw new MessagingException("Exception thrown in getTo() parsing: " + addressList, e);        }        if (iaarray.length == 0) {            throw new MessagingException("Failed to initialize \"to\" list; empty <to> init parameter found.");        }        return iaarray;    }    /**     * Gets the <CODE>to</CODE> property,     * built dynamically using the original Mail object.     * Its outcome will be the the value the <I>TO:</I> header will be set to,     * that could be different from the real recipient (see {@link #getRecipients}).     * Is a "getX(Mail)" method.     *     * @return {@link #replaceInternetAddresses} on {@link #getRecipients()},     */    protected InternetAddress[] getTo(Mail originalMail) throws MessagingException {        InternetAddress[] apparentlyTo = (isStatic()) ? this.apparentlyTo : getTo();        if (apparentlyTo != null) {            if (   apparentlyTo.length == 1                && (   apparentlyTo[0].equals(SpecialAddress.UNALTERED.toInternetAddress())                    || apparentlyTo[0].equals(SpecialAddress.TO.toInternetAddress())                    )) {                apparentlyTo = null;            } else {                Collection toList = new ArrayList(apparentlyTo.length);                for (int i = 0; i < apparentlyTo.length; i++) {                    toList.add(apparentlyTo[i]);                }                /* IMPORTANT: setTo() treats null differently from a zero length array,                  so it's ok to get a zero length array from replaceSpecialAddresses                 */                apparentlyTo = (InternetAddress[]) replaceInternetAddresses(originalMail, toList).toArray(new InternetAddress[0]);            }        }                return apparentlyTo;    }    /**     * Sets the "To:" header of <I>newMail</I> to <I>to</I>.     * If the requested value is null does nothing.     * Is a "setX(Mail, Tx, Mail)" method.     */    protected void setTo(Mail newMail, InternetAddress[] to, Mail originalMail) throws MessagingException {        if (to != null) {            newMail.getMessage().setRecipients(Message.RecipientType.TO, to);            if (isDebug) {                log("apparentlyTo set to: " + arrayToString(to));            }        }    }    /**     * Gets the <CODE>replyto</CODE> property.     * Returns the Reply-To address of the new message,     * or null if no change is requested.     * Is a "getX()" method.     *     * @return the <CODE>replyto</CODE> init parameter     * or the postmaster address     * or <CODE>SpecialAddress.SENDER</CODE>     * or <CODE>SpecialAddress.UNALTERED</CODE>     * or <CODE>SpecialAddress.NULL</CODE>     * or <CODE>null</CODE> if missing     */    protected MailAddress getReplyTo() throws MessagingException {        String addressString = getInitParameter("replyTo");        if (addressString == null) {            addressString = getInitParameter("replyto");        }        if(addressString != null) {            MailAddress specialAddress = getSpecialAddress(addressString,                                            new String[] {"postmaster", "sender", "null", "unaltered"});            if (specialAddress != null) {                return specialAddress;            }            try {                return new MailAddress(addressString);            } catch(Exception e) {                throw new MessagingException("Exception thrown in getReplyTo() parsing: " + addressString, e);            }        }        return null;    }    /**     * Gets the <CODE>replyTo</CODE> property,     * built dynamically using the original Mail object.     * Is a "getX(Mail)" method.     *     * @return {@link #getReplyTo()}     * replacing <CODE>SpecialAddress.UNALTERED</CODE> if applicable with null     * and <CODE>SpecialAddress.SENDER</CODE> with the original mail sender     */    protected MailAddress getReplyTo(Mail originalMail) throws MessagingException {        MailAddress replyTo = (isStatic()) ? this.replyTo : getReplyTo();        if (replyTo != null) {            if (replyTo == SpecialAddress.UNALTERED) {                replyTo = null;            } else if (replyTo == SpecialAddress.SENDER) {                replyTo = originalMail.getSender();            }        }        return replyTo;    }    /**     * <P>Sets the "Reply-To:" header of <I>newMail</I> to <I>replyTo</I>.</P>     * If the requested value is <CODE>SpecialAddress.NULL</CODE> will remove the "Reply-To:" header.     * If the requested value is null does nothing.</P>     * Is a "setX(Mail, Tx, Mail)" method.     */    protected void setReplyTo(Mail newMail, MailAddress replyTo, Mail originalMail) throws MessagingException {        if(replyTo != null) {            InternetAddress[] iart = null;            if (replyTo != SpecialAddress.NULL) {                iart = new InternetAddress[1];                iart[0] = replyTo.toInternetAddress();            }                        // Note: if iart is null will remove the header            newMail.getMessage().setReplyTo(iart);                        if (isDebug) {                log("replyTo set to: " + replyTo);            }        }    }    /**     * Gets the <CODE>reversePath</CODE> property.     * Returns the reverse-path of the new message,     * or null if no change is requested.     * Is a "getX()" method.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -