nginx 配置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
mail {
auth_http 127.0.0.1:8080/auth.jsp;
pop3_capabilities "TOP" "USER";
imap_capabilities "IMAP4rev1" "UIDPLUS";

server {
listen 110;
protocol pop3;
proxy on;
}

server {
listen 143;
protocol imap;
proxy on;
}
server {
listen 25;
protocol smtp;
#smtp_auth plain;
xclient off;
proxy on;
}
}

auth.jsp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String userName= request.getHeader("auth-user");
String passwd=request.getHeader("auth-pass");
String protocol=request.getHeader("auth-protocol");
if(protocol!=null){
protocol=protocol.toLowerCase();
}

String server="192.168.0.9"; //根据用户的所在地,修改相应的邮件服务器内网IP
String port="25";
if ("imap".equals(protocol)) {
port="143";
}
else if ("smtp".equals(protocol)) {
port="25";
}else if ("pop3".equals(protocol)) {
port="110";
}
//连接LDAP或者其他方式,判断用户的账号密码是否正确,如果错误 response.setHeader("Auth-Status","ERROR");

response.setHeader("Auth-Status","OK");//用户账号密码正确
response.setHeader("Auth-Server",server);
response.setHeader("Auth-Port",port);
response.setHeader("Auth-Pass",passwd);
response.setHeader("Auth-User",userName);

%>

文件打包下载