亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? smtpclient.java

?? 使用java編寫的手機郵件系統
?? JAVA
字號:
/****************************************************************************** * Mail4ME - Mail for the Java 2 Micro Edition * * A lightweight, J2ME- (and also J2SE-) compatible package for sending and * receiving Internet mail messages using the SMTP and POP3 protocols. * * Copyright (c) 2000-2002 J鰎g Pleumann <joerg@pleumann.de> * * Mail4ME is part of the EnhydraME family of projects. See the following web * sites for more information: * * -> http://mail4me.enhydra.org * -> http://me.enhydra.org * * Mail4ME is distributed under the Enhydra Public License (EPL), which is * discussed in great detail here: * * -> http://www.enhydra.org/software/license/index.html * * Have fun! ******************************************************************************/package de.trantor.mail;import java.io.InputStream;import java.io.OutputStream;import java.io.IOException;import java.util.Vector;/** * Encapsulates the SMTP protocol, as specified in RFC 822. This class is used * to send messages across the internet. After an SMTP session has been * established using the open() method, an arbitrary number of messages can * be sent using the two variants of the sendMessage() method. One variant sends * a message already contained in an envelope, the other one creates the * envelope on-the-fly. Each SMTP session should be terminated by a call to the * close() method. * * @see Pop3Client * @see Envelope * @see Message */public class SmtpClient {    /**     * Holds the socket used for communication with the SMTP server.     */    private Connection connection;    /**     * Holds the hostname of the machine the SMTP client is working on.     */    private String localhost;    /**     * Constructs an instance of the SMTP client. The hostname of the local (!)     * machine is needed during the initial handshaking of the SMTP protocol.     * Unfortunately J2ME/MIDP provides no means to find out the name or IP of     * the local host, so we have to specify it here to be compatible to all     * possible environments.     * <p>     * Some explanation might be handy here, since the localhost parameter     * seems to be a source of confusion: Actually, there is *some* value     * needed during initial SMTP handshaking. The SMTP specification says that     * this value should identify the client machine, but most servers don't     * seem to actually use the passed value, but check the client's IP number     * instead (if it checks something at all). Yet, it is possible that there     * are hosts that allow access only to "known" clients based on this value.     * So, in most cases passing null or "localhost" will be ok. If you run into     * problems with a specific host, try to pass a sensible value here.     */    public SmtpClient(String localhost) {        this(null, localhost);    }    public SmtpClient(Connection connection, String localhost) {        if (connection == null) connection = Connection.getInstance();        if (localhost == null) localhost = "localhost";        this.connection = connection;        this.localhost = localhost;    }    /**     * Opens a connection to the given server at the well-known port 25. No     * username or password is required, which is ok for most SMTP servers,     * since SMTP is basically not password-protected.     *     * @see #open(String, int, boolean, String, String)     * @see #close     * @see #connected     */    public void open(String host) throws IOException, MailException {        open(host, 0, false, null, null);    }    /**     * Opens a connection to the given server at the given port and using     * secure sockets, if desired. In addition, authentication is tried if     * both the user and the pass parameters are non-null.     * <p>     * A note on authentication: It requires an ESMTP server that actually     * allows authentication. Only the PLAIN method is supported, which expects     * the username and password information to be passed in one MIME-encoded     * string. Other methods are too costly in terms of code, so they're not     * supported (yet).     *     * @see #open(String)     * @see #close     * @see #connected     */    public void open(String host, int port, boolean ssl, String user, String pass) throws IOException, MailException {        /**         * Terminate any open session first.         */        if (connected()) close();        /**         * Create a connection object matching the current environment (J2ME or         * J2SE) using the factory method of Connection, then open the socket.         */        connection.open(host, (port == 0 ? 25 : port), ssl);        /**         * Swallow the initial 'hello' line from the server, then do initial         * handshaking. If something goes wrong, close the whole session.         */        try {            execute(null);            if ((user != null) && (pass != null)) {                execute("EHLO " + localhost);                execute("AUTH PLAIN " + getAuthString(user, pass));            }            else {                execute("HELO " + localhost);            }        }        catch (MailException e) {            connection.close();            throw e;        }    }    /**     * Ends the SMTP session. This method should be called after access to the     * SMTP server, in order to close the underlying socket connection and     * thus free resources.     *     * @see #open     * @see #connected     */    public void close() throws IOException, MailException {        if (connected()) {            execute("QUIT");            connection.close();        }    }    /**     * Returns true, if the client is currently connected to an SMTP server.     *     * @see #open     * @see #close     */    public boolean connected() {        return connection.connected();    }    /**     * Handles a request/response pair. This is a convenience method used     * internally to handle sending a request to the SMTP server as well as     * receiving the response. If the response starts with a result code greater     * than or equal to 400, and thus denotes a protocol error, an exception is     * raised to reflect it. Note that the request is only sent if it doesn't     * equal null, while the response is always being waited for.     *     * @see #send     * @see #receive     * @see MailException     */    private String execute(String command) throws IOException, MailException {        if (command != null) connection.send(command);        String line = connection.receive();        String result = line;        while ((line.length() >= 4) && (line.charAt(3) == '-')) {            line = connection.receive();            result = result + line.substring(3);        }        char c = result.charAt(0);        if ((c == '4') || (c == '5')) {            throw new MailException(result);        }        return result;    }    /**     * Sends a message. This is a convenience method that automatically creates     * an envelope for the message before sending it to the SMTP server. Note     * that the message headers must contain a valid "From:" field and at least     * one of "To:", "CC:" or "BCC:" for the method to work properly. This is     * because the method attempts to copy envelope addressing information from     * the message headers.     *     * @see #sendMessage(de.trantor.mail.Envelope)     * @see Envelope     * @see Message     */    public void sendMessage(Message message) throws IOException, MailException {        sendMessage(new Envelope(message, true));    }    /**     * Sends a message. This method is used to send a message that is already     * enclosed in an envelope. Note that the envelope must contain a valid     * sender field and at least one recipient for the method to work properly.     *     * @see #sendMessage(de.trantor.mail.Message)     * @see Envelope     * @see Message     */    public void sendMessage(Envelope envelope) throws IOException, MailException {        /**         * First of all the SMTP server wants to know the message's initiator.         */        execute("MAIL FROM: <" + Message.getMachineAddress(envelope.getSender()) + ">");        /**         * Next we have to specify all the message's recipients.         */        for (int i = 0; i < envelope.getRecipientCount(); i++) {            String[] list = Message.getStringElements(envelope.getRecipient(i), ',');            for (int j = 0; j < list.length; j++) {                execute("RCPT TO: <" + Message.getMachineAddress(list[j]) + ">");            }        }        /**         * Finally, we transmit the message headers and body. The message's internal         * representation already contains the empty line that is used to separate         * the header and body parts, so we don't have to insert it ourselves.         */        execute("DATA");        Vector lines = envelope.getMessage().getLines();        for (int i = 0; i < lines.size(); i++) {            String s = (String)lines.elementAt(i);            /**             * Do byte-stuffing, if necessary. Byte-stuffing takes place when a             * line starts with a dot: A second dot is prepended to the line in             * that case, to help the SMTP server distinguish the end of a multiline             * request (a line containing a dot only) from lines intentionally             * starting with a dot.             */            if ((s.length() != 0) && (s.charAt(0) == '.')) {                s = '.' + s;            }            connection.send(s);        }        /**         * The whole message is terminated by a line that contains a single dot         * only.         */        execute(".");    }    /**     * Queries whether the SMTP client is in debug mode or not.     */    public boolean getDebug() {        return connection.getDebug();    }    /**     * Controls printing of protocol debugging information to standard output.     */    public void setDebug(boolean value) {        connection.setDebug(value);    }    /**     * Encodes SMTP authentication data. This method is used to derive the     * MIME-encoded authentication string for secure SMTP servers.     * <p>     * Contains code from Stefan Haustein's KObjects library (www.kobjects.org)     * used by permission.     *     * @see #open(String, int, boolean, String, String)     */    private static String getAuthString(String user, String pass) {        char[] charTab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();        byte[] data = ("\000" + user + "\000" + pass).getBytes();        StringBuffer buf = new StringBuffer();        int start = 0;        int len = data.length;        int end = len - 3;        int i = start;        while (i <= end) {            int d = ((((int) data [i]) & 0x0ff) << 16)                | ((((int) data [i+1]) & 0x0ff) << 8)                | (((int) data [i+2]) & 0x0ff);            buf.append(charTab [(d >> 18) & 63]);            buf.append(charTab [(d >> 12) & 63]);            buf.append(charTab [(d >> 6) & 63]);            buf.append(charTab [d & 63]);            i += 3;        }        if (i == start + len - 2) {            int d = ((((int) data [i]) & 0x0ff) << 16)                | ((((int) data [i+1]) & 255) << 8);            buf.append(charTab [(d >> 18) & 63]);            buf.append(charTab [(d >> 12) & 63]);            buf.append(charTab [(d >> 6) & 63]);            buf.append("=");        }        else if (i == start + len - 1) {            int d = (((int) data [i]) & 0x0ff) << 16;            buf.append(charTab [(d >> 18) & 63]);            buf.append(charTab [(d >> 12) & 63]);            buf.append("==");        }        return buf.toString();    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本久久电影网| 99精品在线观看视频| 国产精品亲子乱子伦xxxx裸| 色激情天天射综合网| 日产国产高清一区二区三区| 91精品国产欧美一区二区| 国产老肥熟一区二区三区| 久久久九九九九| 欧美日韩一二三区| 国产精品资源在线| 亚洲综合久久久久| 日本一区二区三区四区在线视频| 色伊人久久综合中文字幕| 日韩av电影天堂| 国产精品久久夜| 精品捆绑美女sm三区| 91美女在线视频| 国产一区二区精品在线观看| 亚洲国产精品久久久男人的天堂| 久久亚洲综合色一区二区三区| 色欧美日韩亚洲| 国产精品一区二区x88av| 中文字幕日韩欧美一区二区三区| 欧美理论在线播放| 91在线你懂得| 国内精品伊人久久久久av影院| 亚洲尤物在线视频观看| 亚洲欧美一区二区三区孕妇| 精品伦理精品一区| 欧美顶级少妇做爰| 99国产精品久久久久| 国产另类ts人妖一区二区| 奇米色一区二区| 香蕉av福利精品导航| 亚洲免费观看在线视频| 欧美高清在线一区二区| 久久免费的精品国产v∧| 日韩一级片网站| 欧美日韩高清一区| 91啪亚洲精品| 99re8在线精品视频免费播放| 久久精品免费观看| 男人的j进女人的j一区| 五月天久久比比资源色| 一区二区三区在线观看欧美| 国产亚洲欧美中文| 欧美成人一区二区三区| 欧美一区二区三区喷汁尤物| 欧美日韩在线一区二区| 日本韩国一区二区| 在线亚洲一区观看| 91农村精品一区二区在线| 成人午夜免费电影| 国产一区二区伦理| 热久久免费视频| 美腿丝袜亚洲三区| 狠狠狠色丁香婷婷综合激情| 国精产品一区一区三区mba视频 | 久久无码av三级| 欧美精品 国产精品| 91精品免费在线观看| 欧美精品1区2区3区| 欧美一级专区免费大片| 精品三级在线观看| 久久久久国产精品人| 久久精品人人做人人综合| 中文av一区二区| 国产精品久久久久久久久免费樱桃| 国产日产欧产精品推荐色| 欧美国产日韩一二三区| 国产精品国产三级国产aⅴ入口| 欧美韩国一区二区| 亚洲精品中文在线观看| 亚洲一区二区美女| 日本aⅴ亚洲精品中文乱码| 韩国在线一区二区| 国产成人午夜精品5599| 91日韩精品一区| 欧美日韩视频在线第一区 | 99久久精品国产观看| 91天堂素人约啪| 欧美日韩另类一区| 日韩欧美国产wwwww| 久久久一区二区| 亚洲欧洲成人精品av97| 视频在线观看91| 激情av综合网| 成人av在线播放网站| 色综合av在线| 欧美一区二区三区啪啪| 国产欧美日韩久久| 一二三区精品视频| 青青草原综合久久大伊人精品 | 中文字幕欧美国产| 婷婷综合另类小说色区| 国产精品77777| 欧美亚洲禁片免费| 久久久国产一区二区三区四区小说| 国产精品传媒在线| 日本在线观看不卡视频| 韩国一区二区三区| 欧美日韩一区三区四区| 欧美精品一区二区三区视频| 亚洲欧洲综合另类在线| 国产一区二区中文字幕| 欧美制服丝袜第一页| 久久这里只有精品首页| 亚洲精品videosex极品| 国产精品资源网站| 欧美日韩激情在线| 国产精品区一区二区三区| 亚洲超碰精品一区二区| 高清国产一区二区| 91精品婷婷国产综合久久| 中文字幕制服丝袜成人av| 丝袜美腿亚洲综合| 91免费看视频| 国产亚洲欧美日韩俺去了| 亚洲成a人片在线不卡一二三区| 国产夫妻精品视频| 欧美日韩一区成人| 国产精品免费久久| 国内国产精品久久| 欧美高清激情brazzers| 最近中文字幕一区二区三区| 国产乱子伦视频一区二区三区| 欧美精品在线一区二区| 亚洲精品一二三| 成人永久免费视频| 欧美日韩精品免费观看视频| 国产日产欧美一区二区视频| 美日韩一区二区| 91麻豆精品国产自产在线 | 日韩精品乱码免费| 欧美专区日韩专区| 亚洲精品乱码久久久久久日本蜜臀| 国产毛片一区二区| 欧美一区二区三区播放老司机| 一区二区不卡在线播放 | 日本一区二区三区久久久久久久久不 | 欧美bbbbb| 欧美激情一区不卡| 久久www免费人成看片高清| 色老汉一区二区三区| 亚洲欧美视频一区| 91国在线观看| 亚洲国产日产av| 91精品国产综合久久久久久久| 亚洲男人的天堂av| 色播五月激情综合网| 亚洲一区二区三区四区五区中文| 欧美综合欧美视频| 日韩va欧美va亚洲va久久| 日韩欧美国产不卡| 国产激情视频一区二区在线观看| 中文字幕第一区二区| 91片黄在线观看| 视频一区二区三区在线| 337p亚洲精品色噜噜噜| 国产一区二区三区免费播放| 国产清纯白嫩初高生在线观看91 | 久久精品噜噜噜成人av农村| 久久精品综合网| 色偷偷一区二区三区| 婷婷中文字幕综合| 久久久久99精品一区| av在线播放一区二区三区| 天天免费综合色| 国产亚洲精品超碰| 色综合天天综合网国产成人综合天 | 97精品超碰一区二区三区| 亚洲国产精品欧美一二99| 精品成人一区二区三区| 99久久久国产精品免费蜜臀| 偷窥少妇高潮呻吟av久久免费| 国产亚洲精品福利| 欧美日韩一区 二区 三区 久久精品 | 天天综合网 天天综合色| 精品国产1区二区| 91免费版在线| 久久99国产精品麻豆| 国产又粗又猛又爽又黄91精品| 欧美自拍丝袜亚洲| 亚洲综合久久久久| 久久久久9999亚洲精品| 欧美视频一区二区三区四区| 国产乱码精品1区2区3区| 亚洲综合成人在线视频| 国产日韩高清在线| 91精品久久久久久久91蜜桃| 99久久精品国产网站| 久久99久久精品欧美| 亚洲欧美日韩久久精品| 久久久精品天堂| 91精品一区二区三区在线观看| 99视频热这里只有精品免费| 精品在线观看免费| 亚洲国产乱码最新视频| 国产精品免费丝袜| 精品国产不卡一区二区三区|