一起学习
private boolean usedParameter(String s, Hashtable hashtable)
{
for(Enumeration enumeration = hashtable.keys(); enumeration.hasMoreElements();)
{
String s1 = (String)hashtable.get((String)enumeration.nextElement());
if(s1.indexOf(s) >= 0)
return true;
}
return false;
}
private void readTemplateFile(String s, Hashtable hashtable)
{
String s4 = "";
boolean flag = false;
try
{
BufferedReader bufferedreader = new BufferedReader(new
InputStreamReader(new FileInputStream(s)));
String s1;
while((s1 = bufferedreader.readLine()) != null)
{
s1 = s1.trim();
if(s1.length() > 0)
{
String s3 = s1.toUpperCase();
if(s3.startsWith("PORT:"))
{
if(flag)
{
hashtable.remove("BODY");
hashtable.put("BODY", s4);
}
flag = false;
s4 = "";
hashtable.remove("PORT");
hashtable.put("PORT", s1.substring("PORT:".length()).trim());
}
else
if(s3.startsWith("DOMAIN:"))
{
if(flag)
{
hashtable.remove("BODY");
hashtable.put("BODY", s4);
}
flag = false;
s4 = "";
hashtable.remove("DOMAIN");
hashtable.put("DOMAIN",
s1.substring("DOMAIN:".length()).trim());
}
else
if(s3.startsWith("TO:"))
{
if(flag)
{
hashtable.remove("BODY");
hashtable.put("BODY", s4);
}
flag = false;
s4 = "";
hashtable.remove("TO");
hashtable.put("TO", s1.substring("TO:".length()).trim());
}
else
if(s3.startsWith("CC:"))
{
if(flag)
{
hashtable.remove("BODY");
hashtable.put("BODY", s4);
}
flag = false;
s4 = "";
hashtable.remove("CC");
hashtable.put("CC", s1.substring("CC:".length()).trim());
}
else
if(s3.startsWith("SUBJECT:"))
{
if(flag)
{
hashtable.remove("BODY");
hashtable.put("BODY", s4);
}
flag = false;
s4 = "";
hashtable.remove("SUBJECT");
hashtable.put("SUBJECT",
s1.substring("SUBJECT:".length()).trim());
}
else
if(s3.startsWith("MAILHOST:"))
{
if(flag)
{
hashtable.remove("BODY");
hashtable.put("BODY", s4);
}
flag = false;
s4 = "";
hashtable.remove("MAILHOST");
hashtable.put("MAILHOST",
s1.substring("MAILHOST:".length()).trim());
}
else
if(s3.startsWith("FROM:"))
{
if(flag)
{
hashtable.remove("BODY");
hashtable.put("BODY", s4);
}
flag = false;
s4 = "";
hashtable.remove("FROM");
hashtable.put("FROM", s1.substring("FROM:".length()).trim());
}
else
if(s3.startsWith("REPLY:"))
{
if(flag)
{
hashtable.remove("BODY");
hashtable.put("BODY", s4);
}
flag = false;
s4 = "";
hashtable.remove("REPLY");
hashtable.put("REPLY", s1.substring("REPLY:".length()).trim());
}
else
if(s3.startsWith("ATTACH:"))
{
if(flag)
{
hashtable.remove("BODY");
hashtable.put("BODY", s4);
}
flag = false;
s4 = "";
hashtable.remove("ATTACH");
hashtable.put("ATTACH",
s1.substring("ATTACH:".length()).trim());
}
else
if(s3.startsWith("ENCODING:"))
{
if(flag)
{
hashtable.remove("BODY");
hashtable.put("BODY", s4);
}
flag = false;
s4 = "";
hashtable.remove("ENCODING");
hashtable.put("ENCODING",
s1.substring("ENCODING:".length()).trim());
}
else
if(s3.startsWith("BODY:"))
{
hashtable.remove("BODY");
flag = true;
s4 = s1.substring("BODY:".length()).trim();
}
else
if(flag)
s4 = s4 NEWLINE s1;
}
else
if(flag)
s4 = s4 NEWLINE;
}
bufferedreader.close();
File file = new File(s);
hashtable.put("edt", String.valueOf(file.lastModified()));
}
catch(Exception _ex) { }
String s2;
if((s2 = (String)hashtable.get("PORT")) != null)
try
{
int i = Integer.parseInt(s2);
if(i <= 0)
hashtable.remove("PORT");
}
catch(Exception _ex)
{
hashtable.remove("PORT");
}
if((s2 = (String)hashtable.get("DOMAIN")) != null && s2.length() == 0)
hashtable.remove("DOMAIN");
if((s2 = (String)hashtable.get("REPLY")) != null && s2.length() == 0)
hashtable.remove("REPLY");
if((s2 = (String)hashtable.get("FROM")) != null && s2.length() == 0)
hashtable.remove("FROM");
if((s2 = (String)hashtable.get("TO")) != null && s2.length() == 0)
hashtable.remove("TO");
if((s2 = (String)hashtable.get("CC")) != null && s2.length() == 0)
hashtable.remove("CC");
if(hashtable.get("PORT") == null)
hashtable.put("PORT", "25");
if(hashtable.get("DOMAIN") == null)
hashtable.put("DOMAIN", "localhost");
if(hashtable.get("ENCODING") == null)
hashtable.put("ENCODING", "ISO-8859-1");
if(flag)
{
hashtable.remove("BODY");
hashtable.put("BODY", s4);
}
}
private String decodeString(String s, String s1, String s2)
{
String s3;
try
{
s3 = new String(s.getBytes(s1 != null ? s1 : "ISO-8859-1"), s2);
}
catch(Exception _ex)
{
s3 = s;
}
return s3;
}
public WapMailer()
{
}
private static final String MAILHOST = "MAILHOST";
private static final String PORT = "PORT";
private static final String DOMAIN = "DOMAIN";
private static final String FROM = "FROM";
private static final String TO = "TO";
private static final String CC = "CC";
private static final String SUBJECT = "SUBJECT";
private static final String BODY = "BODY";
private static final String ATTACH = "ATTACH";
private static final String REPLY = "REPLY";
private static final String FILE = "FILE";
private static final String EDITED = "edt";
private static final String ENCODING = "ENCODING";
private static final String DEFDOMAIN = "localhost";
private static final String DEFENCODING = "ISO-8859-1";
private static final String DEFPORT = "25";
private static String NEWLINE = "\n";
private static Hashtable cfgs;
}
相关连接:
构建WAP邮件发送服务器 (一)
构建WAP邮件发送服务器 (二)
构建WAP邮件发送服务器 (三)
构建WAP邮件发送服务器 (四)
构建WAP邮件发送服务器 (五)
构建WAP邮件发送服务器 (六)
下载本文示例代码
构建WAP邮件发送服务器 (六)构建WAP邮件发送服务器 (六)构建WAP邮件发送服务器 (六)构建WAP邮件发送服务器 (六)构建WAP邮件发送服务器 (六)构建WAP邮件发送服务器 (六)构建WAP邮件发送服务器 (六)构建WAP邮件发送服务器 (六)构建WAP邮件发送服务器 (六)构建WAP邮件发送服务器 (六)构建WAP邮件发送服务器 (六)构建WAP邮件发送服务器 (六)
阅读(194) | 评论(0) | 转发(0) |