////请问该如何来实现?
当然是自己写程序实现。///将附件上传到web页面,然后发送出去,该怎么做?
上传是小问题,我用的jspsmartupload作的,james不直接提供添加删除用户的api,但是你可以改造数据库结构自己自己对数据库操作啊。最难的是自定义文件夹、配置,我还没有实现,虽然有思路,但不想写代码:(
去找james的文档来看吧,虽然比较痛苦,我就是这样过来的。
当然是自己写程序实现。///将附件上传到web页面,然后发送出去,该怎么做?
上传是小问题,我用的jspsmartupload作的,james不直接提供添加删除用户的api,但是你可以改造数据库结构自己自己对数据库操作啊。最难的是自定义文件夹、配置,我还没有实现,虽然有思路,但不想写代码:(
去找james的文档来看吧,虽然比较痛苦,我就是这样过来的。
解决方案 »
- 解析excel问题
- 急~!~hibernet HQL返回值问题~
- 如何通过参数处理文件真实下载地址
- 关于JAVA中 工作流(osworkFlow)的问题
- ==========Hibernate中,既然可以直接返回query.iterator(),为什么很多给例子用query.list().iterator(),两者有何区别===========
- hibernate3配置运行后出现的问题.
- 谁知道哪里有可以做简单的图像处理的Java代码,包括缩放等功能,可以在脱离X窗口环境下运行的。
- SUN J2EE tutorial访问数据库出现异常。
- JBuilder8需要与相关的servlet、JSP的服务器的目录如何设置?
- Tomcat启动报错
- hibernate不解的问题!求助
- 求 聊天室 程序
To pigo(淡是水于火的相容)
谢谢大哥的解答,那能把您的上传的代码帖出来呢,小弟还有一是不明,比如,我通过web浏览方式看我的收件箱,那么整个邮件是存在一起的,连同附件一起,那么请文这时候怎么处理,至少在显示上怎么处理
详见\james-2.2.0-src\proposals\rmi-remotemanagerjmx方式好象还没实现吧,不懂。
package com.hypersoft.ccm.util.mail;import java.net.Socket;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.UnknownHostException;
import java.io.InputStreamReader;
import java.io.PrintStream;/**
* @author wangjb
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class MailServerMng {
private String serverAddress = "localhost";
private int port = 4555;
private String userId = "root"; // administrators userid
private String password = "root"; private Socket connectionSocket = null;
private PrintStream out = System.err;
private BufferedReader in = null;
private boolean connectedStatus; public MailServerMng() {
}
public MailServerMng(String server, int port, String uid, String pwd) {
this.userId = uid;
this.password = pwd;
this.serverAddress = server;
this.port = port;
this.connectedStatus = connect();
} //methods
public void ensure(String _userid, String _password, String _domain)
throws IOException {
if (serverAddress.equalsIgnoreCase(_domain)) {
if (!isConnected()) {
connect();
}
if (verifyUser(_userid)) {
// user exists in james and changing password
if (null != _password && 0 < _password.length())
changePassword(_userid, _password);
} else
addUser(_userid, _password);
// user was not in james and should
} else {
if (!isConnected()) {
connect();
}
if (verifyUser(_userid)) { // user exists in James and should not
delUser(_userid);
}
}
} public boolean isConnected() {
return this.connectedStatus;
} private void disconnect() {
try {
this.out.println("quit");
this.out.close();
this.in.close();
this.connectionSocket.close();
this.connectedStatus = false;
return;
} catch (IOException e) {
this.connectedStatus = false;
log("Couldn't get I/O for " + "the connection to server.");
return;
}
} public boolean connect() {
try {
this.connectionSocket = new Socket(this.serverAddress, this.port);
this.out =
new PrintStream(connectionSocket.getOutputStream(), true);
this.in =
new BufferedReader(
new InputStreamReader(connectionSocket.getInputStream()));
//Login to the server
String userInput;
log(in.readLine());
//wait for the connection
out.println(this.userId);
//send userid
log(in.readLine());
//wait for \n
out.println(this.password);
//send the password
//log (in.readLine());
if (in.readLine().indexOf("HELP") != -1) {
this.connectedStatus = true;
log("Server accepted connection");
return true;
} else {
this.connectedStatus = false;
log("Server refused connection");
return false;
}
} catch (UnknownHostException e) {
this.connectedStatus = false;
log("Unable to connect to the host!");
return false;
} catch (IOException e) {
System.err.println("erreur officiel : \n" + e);
this.connectedStatus = false;
log("Couldn't get I/O for " + "the connection to server.");
return false;
}
} private String execute(String command) throws IOException {
String serverSays;
if (connectedStatus == false)
connect();
// now execute the command
log("executing: -" + command + "-");
out.println(command);
out.println("###");
String returnString = "";
char[] inChars = new char[1];
serverSays = in.readLine();
while (serverSays != null && serverSays.endsWith("###") == false) {
returnString += serverSays + "\n";
serverSays = in.readLine();
}
// log("returning"+returnString);
return returnString;
} public boolean verifyUser(String userName) throws IOException {
if (!isConnected())
connect();
if (!isConnected())
log("broken"); // do something String response = execute("verify " + userName);
// verify if specified user exist
boolean exists = false;
if (null != response && -1 == response.indexOf("does not"))
exists = true; return exists;
} public boolean addUser(String userName, String password)
throws IOException {
if (!isConnected())
connect();
if (!isConnected())
log("broken: no connection to James"); // do something
String response = execute("adduser " + userName + " " + password);
boolean exists = false;
System.err.println("reponse : " + response);
if (null != response) {
if (0 <= response.indexOf("added")) {
exists = true;
} else if (0 <= response.indexOf("already")) {
exists = false;
}
}
return exists;
} public boolean delUser(String _userName, String _domain)
throws IOException {
if (serverAddress.equalsIgnoreCase(_domain)) {
return delUser(_userName);
}
return true; // well, he is not here!
} public boolean delUser(String userName) throws IOException {
if (!isConnected())
connect();
if (!isConnected())
log("broken"); // do something boolean exists = false;
String response = execute("deluser " + userName + " " + password);
if (null != response) {
} else if (0 <= response.indexOf("deleted")) {
exists = true; // was deleted
} else if (0 <= response.indexOf("Error")) {
exists = true; // didn't exist }
return exists;
} public boolean setPassword(String userName, String password)
throws IOException {
if (!isConnected())
connect();
if (!isConnected())
log("broken"); // do something boolean exists = false; String response = execute("setpassword " + userName + " " + password);
if (null != response) {
} else if (0 <= response.indexOf("reset")) {
exists = true; // was deleted
} else if (0 <= response.indexOf("Error")) {
exists = true; // didn't exist }
return exists;
} public boolean changePassword(String userName, String password)
throws IOException {
//if (verifyUser(userName)) // james 2 added setpassword
// delUser(userName);
return setPassword(userName, password);
} private void log(String note) {
System.err.println(getClass().getName() + " " + note);
}}