Example usage for org.apache.commons.net.smtp SMTPConnectionClosedException getMessage

List of usage examples for org.apache.commons.net.smtp SMTPConnectionClosedException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.net.smtp SMTPConnectionClosedException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:autohit.call.modules.TolerantSmtpModule.java

/**
 * Recipient relay method. It will fault if a session has not been started
 * or has expired. It will set the sender as the accumulated relay. You
 * must have called addrecipientrelay() at least once or you will get an
 * error. Subsequent calls will overwrite the value.
 * /*from w w  w . j  a va  2 s .c o m*/
 * @param hostname
 *            hostname to use instead of localhost.
 * @throws CallException
 */
private void recipientrelay() throws CallException {

    // Is it started?
    if (client == null) {
        this.error("Session not start()'ed.");
    }

    // Is there a relay?
    if (recipientrelay == null) {
        this.error(
                "Recipient relay not ready.  You need to call addrecipientrelay() at least once before this method.");
        return;
    }

    try {
        client.addRecipient(recipientrelay);

        // what happened?
        int code = client.getReplyCode();
        if (code >= SMTP_ERROR_THRESHOLD) {
            this.error("Add recipient relay failed with code=" + code + " reply=" + client.getReplyString());
        } else if (this.isDebugging()) {
            this.debug("Add recipient relay complete.  code=" + code);
        }

    } catch (SMTPConnectionClosedException ex) {
        this.done();
        this.error("Cannot add recipient.  Connection expired and closed itself.");
    } catch (Exception ex) {
        this.done();
        this.error("Cannot add recipient due to exception.  message=" + ex.getMessage());
    }

}

From source file:autohit.call.modules.SimpleSmtpModule.java

/**
 * Send the message in a Universe Object. Returns the SMTP reply code.
 * /*from www .ja v  a 2  s. c o  m*/
 * @param hostname
 *           hostname to use instead of localhost.
 * @throws CallException
 */
private String senduni(String uniobject) throws CallException {

    String result = ERROR_STRING_FOR_FAILURE;

    // Is it started?
    if (client == null) {
        this.fault("Session not start()'ed.");
    }

    try {
        // get the hoses
        InputStream unio = visUniverse.getStream(uniobject);
        BufferedReader bin = new BufferedReader(new InputStreamReader(unio));
        Writer mwriter = client.sendMessageData();

        // and pipe them together
        if (mwriter != null) {
            Util.copyReader(bin, mwriter);
            mwriter.close();
            unio.close();
            client.completePendingCommand(); // don't care if it was ok.

            // what happened?
            int code = client.getReplyCode();
            if (code >= SMTP_ERROR_THRESHOLD) {
                this.error("Message send FAILED (from Universe).  code=" + code + " reply="
                        + client.getReplyString());
            } else if (this.isDebugging()) {
                this.debug("Message send complete (from Universe).  code=");
            }
            result = Integer.toString(code);

        } else {
            this.log("Message send FAILED (from Universe) because SMTP connection was completely ready.  reply="
                    + client.getReplyString());
        }

    } catch (UniverseException uex) {
        this.fault("Could not send universe object due to Universe problem.  code=" + uex.numeric + "  message="
                + uex.getMessage(), uex);
    } catch (SMTPConnectionClosedException ex) {
        this.done();
        this.fault("Send failed (from Universe).  Connection expired and closed itself.");
    } catch (Exception ex) {
        this.done();
        this.fault("Send failed (from Universe) due to exception.  message=" + ex.getMessage());
    }
    return result;
}

From source file:autohit.call.modules.SimpleSmtpModule.java

/**
 * Send the message in a Universe Object. Returns the SMTP reply code. It
 * will run a variable replace on it before sending it.
 * //from  ww  w.j a v  a2 s . c  o  m
 * @param hostname
 *           hostname to use instead of localhost.
 * @throws CallException
 */
private String senduniscrub(String uniobject) throws CallException {

    String result = ERROR_STRING_FOR_FAILURE;
    String tempObj = null;

    // Is it started?
    if (client == null) {
        this.fault("Session not start()'ed.");
    }

    try {

        // Process it
        try {
            tempObj = visUniverse.reserveUnique(TEMPFILE);
            String thing = UniverseUtils.load2String(visUniverse.getStream(uniobject));
            String thang = StringProcessors.evalString2Core(thing, visCore);
            OutputStream os = visUniverse.putStream(tempObj);
            UniverseUtils.saveString(os, thang);

        } catch (UniverseException ue) {
            throw ue;
        } catch (Exception e) {
            this.fault(
                    "Send failed (from Universe).  Could not create scrubbed intermediary tempfile.  message="
                            + e.getMessage());
        }

        // get the hoses
        InputStream unio = visUniverse.getStream(tempObj);
        BufferedReader bin = new BufferedReader(new InputStreamReader(unio));
        Writer mwriter = client.sendMessageData();

        // and pipe them together
        if (mwriter != null) {
            Util.copyReader(bin, mwriter);
            mwriter.close();
            unio.close();
            client.completePendingCommand(); // don't care if it was ok.

            // what happened?
            int code = client.getReplyCode();
            if (code >= SMTP_ERROR_THRESHOLD) {
                this.error("Message send FAILED (from Universe).  code=" + code + " reply="
                        + client.getReplyString());
            } else if (this.isDebugging()) {
                this.debug("Message send complete (from Universe).  code=");
            }
            result = Integer.toString(code);

        } else {
            this.log("Message send FAILED (from Universe) because SMTP connection was completely ready.  reply="
                    + client.getReplyString());
        }

    } catch (CallException cex) {
        throw cex;
    } catch (UniverseException uex) {
        this.fault("Could not send universe object due to Universe problem.  code=" + uex.numeric + "  message="
                + uex.getMessage(), uex);
    } catch (SMTPConnectionClosedException ex) {
        this.done();
        this.fault("Send failed (from Universe).  Connection expired and closed itself.");
    } catch (Exception ex) {
        this.done();
        this.fault("Send failed (from Universe) due to exception.  message=" + ex.getMessage());
    } finally {
        if ((!this.isDebugging()) && (tempObj != null)) {
            try {
                visUniverse.remove(tempObj);
            } catch (Exception ee) {
                // Don't care
            }
        }
    }
    return result;
}

From source file:autohit.call.modules.TolerantSmtpModule.java

/**
 * Send the message in the text. Returns the SMTP reply code.
 * /*from w w  w  .  j a  va2 s. c  o m*/
 * @param hostname
 *            hostname to use instead of localhost.
 * @throws CallException
 */
private String send(String text) throws CallException {

    String result = ERROR_STRING_FOR_FAILURE;

    // Is it started?
    if (client == null) {
        this.error("Session not start()'ed.");
    }

    // Is there something to send? PARANOID
    if (text == null) {
        this.error("Nothing to send.");
        return result;
    }

    try {

        client.sendShortMessageData(text);
        //client.completePendingCommand(); // don't care if it was ok.
        result = Integer.toString(client.getReplyCode());

        // what happened?
        int code = client.getReplyCode();
        if (code >= SMTP_ERROR_THRESHOLD) {
            this.error("Message send FAILED.  code=" + code + " reply=" + client.getReplyString());
        } else if (this.isDebugging()) {
            this.debug("Message send complete.  code=" + code + " reply=" + client.getReplyString());
        }

    } catch (SMTPConnectionClosedException ex) {
        this.done();
        this.error("Send failed.  Connection expired and closed itself." + " last reply="
                + client.getReplyString());
    } catch (Exception ex) {
        this.done();
        this.error("Send failed due to exception.  message=" + ex.getMessage());
    }
    return result;
}

From source file:autohit.call.modules.TolerantSmtpModule.java

/**
 * Send the message in a Universe Object. Returns the SMTP reply code.
 * //  w w  w .  j a  va2  s  .co m
 * @param hostname
 *            hostname to use instead of localhost.
 * @throws CallException
 */
private String senduni(String uniobject) throws CallException {

    String result = ERROR_STRING_FOR_FAILURE;

    // Is it started?
    if (client == null) {
        this.error("Session not start()'ed.");
    }

    try {
        // get the hoses
        InputStream unio = visUniverse.getStream(uniobject);
        BufferedReader bin = new BufferedReader(new InputStreamReader(unio));
        Writer mwriter = client.sendMessageData();

        // and pipe them together
        if (mwriter != null) {
            Util.copyReader(bin, mwriter);
            mwriter.close();
            unio.close();
            client.completePendingCommand(); // don't care if it was ok.

            // what happened?
            int code = client.getReplyCode();
            if (code >= SMTP_ERROR_THRESHOLD) {
                this.error("Message send FAILED (from Universe).  code=" + code + " reply="
                        + client.getReplyString());
            } else if (this.isDebugging()) {
                this.debug("Message send complete (from Universe).  code=");
            }
            result = Integer.toString(code);

        } else {
            this.log("Message send FAILED (from Universe) because SMTP connection was completely ready.  reply="
                    + client.getReplyString());
        }

    } catch (UniverseException uex) {
        this.fault("Could not send universe object due to Universe problem.  code=" + uex.numeric + "  message="
                + uex.getMessage(), uex);
    } catch (SMTPConnectionClosedException ex) {
        this.done();
        this.error("Send failed (from Universe).  Connection expired and closed itself.  Last reply="
                + client.getReplyString());
    } catch (Exception ex) {
        this.done();
        this.error("Send failed (from Universe) due to exception.  message=" + ex.getMessage());
    }
    return result;
}

From source file:autohit.call.modules.TolerantSmtpModule.java

/**
 * Send the message in a Universe Object. Returns the SMTP reply code. It
 * will run a variable replace on it before sending it.
 * /*from w ww  .  ja  v a  2  s.  c  o m*/
 * @param hostname
 *            hostname to use instead of localhost.
 * @throws CallException
 */
private String senduniscrub(String uniobject) throws CallException {

    String result = ERROR_STRING_FOR_FAILURE;
    String tempObj = null;

    // Is it started?
    if (client == null) {
        this.error("Session not start()'ed.");
    }

    try {

        // Process it
        try {
            tempObj = visUniverse.reserveUnique(TEMPFILE);
            OutputStream os = visUniverse.putStream(tempObj);
            StringProcessors.evalStreams2Core(visUniverse.getStream(uniobject), os, visCore);
            os.close();

        } catch (UniverseException ue) {
            throw ue;
        } catch (Exception e) {
            this.fault(
                    "Send failed (from Universe).  Could not create scrubbed intermediary tempfile.  message="
                            + e.getMessage());
        }

        // get the hoses
        InputStream unio = visUniverse.getStream(tempObj);
        BufferedReader bin = new BufferedReader(new InputStreamReader(unio));
        Writer mwriter = client.sendMessageData();

        // and pipe them together
        if (mwriter != null) {
            Util.copyReader(bin, mwriter);
            mwriter.close();
            unio.close();
            client.completePendingCommand(); // don't care if it was ok.

            // what happened?
            int code = client.getReplyCode();
            if (code >= SMTP_ERROR_THRESHOLD) {
                this.error("Message send FAILED (from Universe).  code=" + code + " reply="
                        + client.getReplyString());
            } else if (this.isDebugging()) {
                this.debug("Message send complete (from Universe).  code=");
            }
            result = Integer.toString(code);

        } else {
            this.log("Message send FAILED (from Universe) because SMTP connection was completely ready.  reply="
                    + client.getReplyString());
        }

    } catch (CallException cex) {
        throw cex;
    } catch (UniverseException uex) {
        this.fault("Could not send universe object due to Universe problem.  code=" + uex.numeric + "  message="
                + uex.getMessage(), uex);
    } catch (SMTPConnectionClosedException ex) {
        this.done();
        this.error("Send failed (from Universe).  Connection expired and closed itself.  Last reply="
                + client.getReplyString());
    } catch (Exception ex) {
        this.done();
        this.error("Send failed (from Universe) due to exception.  message=" + ex.getMessage());
    } finally {
        if ((!this.isDebugging()) && (tempObj != null)) {
            try {
                visUniverse.remove(tempObj);
            } catch (Exception ee) {
                // Don't care
            }
        }
    }
    return result;
}