本文整理匯總了Java中com.sun.mail.util.MailConnectException類的典型用法代碼示例。如果您正苦於以下問題:Java MailConnectException類的具體用法?Java MailConnectException怎麽用?Java MailConnectException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MailConnectException類屬於com.sun.mail.util包,在下文中一共展示了MailConnectException類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: protocolConnect
import com.sun.mail.util.MailConnectException; //導入依賴的package包/類
protected synchronized boolean protocolConnect(String host, int portNum,
String user, String passwd) throws MessagingException {
// check for non-null values of host, password, user
if (host == null || passwd == null || user == null)
return false;
// if port is not specified, set it to value of mail.pop3.port
// property if it exists, otherwise default to 110
if (portNum == -1)
portNum = PropUtil.getIntSessionProperty(session,
"mail." + name + ".port", -1);
if (portNum == -1)
portNum = defaultPort;
this.host = host;
this.portNum = portNum;
this.user = user;
this.passwd = passwd;
try {
port = getPort(null);
} catch (EOFException eex) {
throw new AuthenticationFailedException(eex.getMessage());
} catch (SocketConnectException scex) {
throw new MailConnectException(scex);
} catch (IOException ioex) {
throw new MessagingException("Connect failed", ioex);
}
return true;
}