📄 emailgateway.java
字号:
* By default the value is null, which means that no username will be used.
*
* @param username the POP3 username.
*/
public void setPOP3Username(String username) {
gateway.setUsername(username);
}
/**
* Returns the password that will be used when connection to the POP3 server.
* By default the value is null, which means that no password will be used.
*
* @return the POP3 password.
*/
public String getPOP3Password() {
return gateway.getPassword();
}
/**
* Sets the password that will be used when connecting to the POP3 server.
* By default the value is null, which means that no password will be used.
*
* @param password the POP3 password.
*/
public void setPOP3Password(String password) {
gateway.setPassword(password);
}
/**
* Returns true if the POP3 delete flag is set. When true, messages will be
* deleted from the server after being downloaded. The default value is
* false.
*
* @return true if messages will be deleted from the POP3 server after
* being downloaded.
*/
public boolean isPOP3DeleteEnabled() {
return gateway.isDeleteEnabled();
}
/**
* Toggles the POP3 delete flag. When true, messages will be
* deleted from the server after being downloaded. The default value is
* false.
*
* @param POP3DeleteEnabled true if messages should be deleted from the
* POP3 server after being downloaded.
*/
public void setPOP3DeleteEnabled(boolean POP3DeleteEnabled) {
gateway.setDeleteEnabled(POP3DeleteEnabled);
}
/**
* Returns the SMTP host (e.g. mail.example.com). The host is null by
* default, but must be set before gateway exports can execute.
*
* @return the SMTP host.
*/
public String getSMTPHost() {
return SMTPHost;
}
/**
* Sets the SMTP host (e.g. mail.example.com). The host is null by
* default, but must be set before gateway exports can execute.
*
* @param host the SMTP host.
*/
public synchronized void setSMTPHost(String host) {
this.SMTPHost = host;
// JavaMail Session no longer valid so set to null; it will get
// recreated as needed.
SMTPSession = null;
}
/**
* Returns the port number that will be used when connecting to the SMTP
* server. The default is 25, the standard SMTP port number.
*
* @return the SMTP port number.
*/
public int getSMTPPort() {
return SMTPPort;
}
/**
* Sets the port number that will be used when connecting to the SMTP
* server. The default is 25, the standard SMTP port number.
*
* @param port the SMTP port number.
*/
public synchronized void setSMTPPort(int port) {
this.SMTPPort = port;
// JavaMail Session no longer valid so set to null; it will get
// recreated as needed.
SMTPSession = null;
}
/**
* Returns the username that will be used when connecting to the SMTP
* server. The default is null, or no username.
*
* @return the SMTP username.
*/
public String getSMTPUsername() {
return SMTPUsername;
}
/**
* Sets the username that will be used when connecting to the SMTP
* server. The default is null, or no username.
*
* @param port the SMTP username.
*/
public synchronized void setSMTPUsername(String username) {
this.SMTPUsername = username;
// JavaMail Session no longer valid so set to null; it will get
// recreated as needed.
SMTPSession = null;
}
/**
* Returns the password that will be used when connecting to the SMTP
* server. The default is null, or no password.
*
* @return the SMTP password.
*/
public String getSMTPPassword() {
return SMTPPassword;
}
/**
* Sets the username that will be used when connecting to the SMTP
* server. The default is null, or no username.
*
* @param port the SMTP password.
*/
public synchronized void setSMTPPassword(String password) {
this.SMTPPassword = password;
// JavaMail Session no longer valid so set to null; it will get
// recreated as needed.
SMTPSession = null;
}
/**
* Returns true if debugging is turned on for the email transport layers.
* Debug information is written to <tt>System.out</tt> by the underlying
* JavaMail provider.
*
* @return true if debugging is turned on.
*/
public boolean isDebugEnabled() {
return debugEnabled;
}
/**
* Toggles SMTP transport layer debugging on or off. Debug information is
* written to <tt>System.out</tt> by the underlying JavaMail provider.
*
* @param debug true if SMTP debugging should be enabled.
*/
public synchronized void setDebugEnabled(boolean debugEnabled) {
this.debugEnabled = debugEnabled;
gateway.setDebugEnabled(debugEnabled);
// JavaMail SMTP Session no longer valid so set to null; it will get
// recreated as needed.
SMTPSession = null;
}
/**
* Returns the body that will be used when creating temporary parent
* messages. It's possible with email accounts and mailing
* lists to get a response to a message before getting the original message.
* If this happens and only the child message is available at the time of
* the gateway import, Jive must still have a way to establish a correct
* parent/child relationship. Therefore, a temporary fake parent message is
* created using an extrapolated subject from the child, and a body with the
* value <tt>temporaryParentBody</tt>. By default, this value will be
* the empty String. However, you may wish to create a short message that
* explains the nature of the fake parent message to the user.<p>
*
* On subsequent imports when a real parent message is found, the fake
* data will be replaced with the correct subject and body.<p>
*
* @return the message body that will be used for temporary fake parent
* messages.
*/
public String getTemporaryParentBody() {
return gateway.getTemporaryParentBody();
}
/**
* Sets the body that will be used when creating temporary parent
* messages. It's possible with email accounts and mailing
* lists to get a response to a message before getting the original message.
* If this happens and only the child message is available at the time of
* the gateway import, Jive must still have a way to establish a correct
* parent/child relationship. Therefore, a temporary fake parent message is
* created using an extrapolated subject from the child, and a body with the
* value <tt>temporaryParentBody</tt>. By default, this value will be
* the empty String. However, you may wish to create a short message that
* explains the nature of the fake parent message to the user.<p>
*
* On subsequent imports when a real parent message is found, the fake
* data will be replaced with the correct subject and body.<p>
*
* @param temporaryParentBody the message body that will be used for
* temporary fake parent messages.
*/
public void setTemporaryParentBody(String temporaryParentBody) {
gateway.setTemporaryParentBody(temporaryParentBody);
}
/**
* Returns true if a user's privacy setting on their email address should be
* obeyed when doing an export.
*
* @return true if a user's privacy settings are respected during exports.
*/
public boolean isEmailPrefEnabled() {
return emailPrefEnabled;
}
/**
* Toggles whether a user's privacy setting on their email address should be
* obeyed when doing an export.
*
* @param enabled true if a user's privacy settings are respected during
* exports.
*/
public void setEmailPrefEnabled(boolean enabled) {
this.emailPrefEnabled = enabled;
}
/**
* Returns the email address that messages will be sent to during exports.
* If the gateway is for a mailing list, this would be the mailing list
* address (e.g., <tt>your-list@example.com</tt>).
*
* @return the email address that will receive exported messages.
*/
public String getToAddress() {
return toAddress;
}
/**
* Sets the email address that messages will be sent to during exports.
* If the gateway is for a mailing list, this would be the mailing list
* address (e.g., <tt>your-list@example.com</tt>).
*
* @param address the email address that will receive exported messages.
*/
public void setToAddress(String address) {
if ("".equals(address)) {
address = null;
}
this.toAddress = address;
}
public String getDefaultFromAddress() {
return defaultFromAddress;
}
public void setDefaultFromAddress(String address) {
if ("".equals(address)) {
address = null;
}
this.defaultFromAddress = address;
}
//OTHER//
/**
* An extension of the JavaMailGateway class that performs imports
* through POP3.
*/
private class POP3Gateway extends JavaMailGateway {
public POP3Gateway(ForumFactory factory, Forum forum) {
super(factory, forum);
setPort(110);
setProtocol("pop3");
setMailbox("INBOX"); // only choice for Sun's POP3 provider.
gatewayMessageId = GATEWAY_MESSAGE_ID;
gatewayParentId = GATEWAY_PARENT_ID;
}
public void exportData(ForumMessage message) throws GatewayException {
// Exporting via POP3 can't be done.
throw new UnsupportedOperationException();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -