一起学习
public String getServletInfo()
{
return "WapMailer mailto: waynezheng@chinaren.com";
}
private boolean letterToNet(Hashtable hashtable, Hashtable hashtable1)
{
smtpMail smtpmail = new smtpMail();
String s1 = prepareString((String)hashtable1.get("MAILHOST"), hashtable);
String s2 = prepareString((String)hashtable1.get("DOMAIN"), hashtable);
int i;
try
{
i = Integer.parseInt(prepareString((String)hashtable1.get("PORT"),
hashtable));
}
catch(Exception _ex)
{
return false;
}
if(s1 == null)
return false;
String s;
String s3;
if((s = (String)hashtable1.get("FROM")) == null)
s3 = (String)hashtable.get("FROM");
else
if(s.indexOf("$") < 0)
s3 = (String)hashtable.get("FROM");
else
s3 = prepareString(s, hashtable);
String s4;
if((s = (String)hashtable1.get("TO")) == null)
s4 = (String)hashtable.get("TO");
else
if(s.indexOf("$") < 0)
s4 = (String)hashtable.get("TO");
else
s4 = prepareString(s, hashtable);
if(smtpmail.open(s1, i) != 1)
return false;
smtpmail.setDomain(s2);
smtpmail.setFrom(s3);
smtpmail.setTo(s4);
if((s = (String)hashtable1.get("SUBJECT")) == null)
s = (String)hashtable.get("SUBJECT");
else
if(s.indexOf("$") < 0)
s = (String)hashtable.get("SUBJECT");
else
s = prepareString(s, hashtable);
smtpmail.addHeader("Subject", s);
if((s = (String)hashtable1.get("CC")) == null)
s = "";
else
s = prepareString(s, hashtable);
if(s.length() > 0)
smtpmail.addHeader("Cc", s);
if((s = (String)hashtable1.get("BODY")) == null)
s = (String)hashtable.get("BODY");
else
if(s.indexOf("$") < 0)
s = (String)hashtable.get("BODY");
else
s = prepareString(insertFiles(s), hashtable);
smtpmail.addData(s);
if((s = (String)hashtable1.get("ATTACH")) != null)
{
s = prepareString(s, hashtable);
for(StringTokenizer stringtokenizer = new StringTokenizer(s, " ,");
stringtokenizer.hasMoreTokens(); smtpmail.addAttachment(s))
s = stringtokenizer.nextToken();
}
if(smtpmail.transmit() != 1)
{
return false;
}
else
{
smtpmail.close();
return true;
}
}
private String insertFiles(String s)
{
String s1 = s.toUpperCase();
int i;
if((i = s1.indexOf("$FILE=")) < 0)
return s;
String s2;
if(i == 0)
s2 = "";
else
s2 = s.substring(0, i) NEWLINE;
s1 = s.substring(i "$FILE=".length());
i = s1.indexOf(NEWLINE);
String s3;
if(i < 0)
{
s3 = "";
}
else
{
s3 = s1.substring(i NEWLINE.length());
s1 = s1.substring(0, i);
}
if(s1.startsWith("\""))
s1 = s1.substring(1);
if(s1.endsWith("\""))
s1 = s1.substring(0, s1.length() - 1);
try
{
BufferedReader bufferedreader = new BufferedReader(new
InputStreamReader(new FileInputStream(s1)));
while((s1 = bufferedreader.readLine()) != null)
s2 = s2 s1 NEWLINE;
bufferedreader.close();
}
catch(Exception _ex)
{
return s;
}
return s2 insertFiles(s3);
}
private String prepareString(String s, Hashtable hashtable)
{
int i = s.indexOf("$");
String s1 = "";
if(i < 0 || i == s.length() - 1)
return s;
for(StringTokenizer stringtokenizer = new StringTokenizer(s, "
,\t;:!@#%^~&*()- _=|\\/?<>" NEWLINE, true); stringtokenizer.hasMoreTokens();)
{
String s2 = stringtokenizer.nextToken();
String s3;
if(s2.startsWith("$"))
{
if(s2.length() == 1)
s1 = s1 s2;
else
if((s3 = (String)hashtable.get(s2.substring(1).toUpperCase())) != null)
s1 = s1 s3;
else
s1 = s1 s2;
}
else
{
s1 = s1 s2;
}
}
return s1;
}
相关连接:
构建WAP邮件发送服务器 (一)
构建WAP邮件发送服务器 (二)
构建WAP邮件发送服务器 (三)
构建WAP邮件发送服务器 (四)
构建WAP邮件发送服务器 (五)
构建WAP邮件发送服务器 (六)
下载本文示例代码
构建WAP邮件发送服务器 (五)构建WAP邮件发送服务器 (五)构建WAP邮件发送服务器 (五)构建WAP邮件发送服务器 (五)构建WAP邮件发送服务器 (五)构建WAP邮件发送服务器 (五)构建WAP邮件发送服务器 (五)构建WAP邮件发送服务器 (五)构建WAP邮件发送服务器 (五)构建WAP邮件发送服务器 (五)构建WAP邮件发送服务器 (五)构建WAP邮件发送服务器 (五)
阅读(204) | 评论(0) | 转发(0) |