/* * created on 2004-12-21 * * todo to change the template for this generated file go to * window - preferences - java - code style - code templates */
/** * @author administrator * * todo to change the template for this generated type comment go to * window - preferences - java - code style - code templates */ public class foxmailmain {
/* * created on 2004-12-21 * * todo to change the template for this generated file go to * window - preferences - java - code style - code templates */
/** * @author administrator * * todo to change the template for this generated type comment go to * window - preferences - java - code style - code templates */ public class foxmail {
private final static byte location_to_screen = 1;//log信息输出位置 1=输出到屏幕 private final static dateformat dateformat = new simpledateformat("yyyy-mm-dd hh:mm:ss");//日志用日期格式 private final static string end_flag = "/r/n";//smtp/esmtp命令结束标记 private final static string email_attach_sign = "=====att";//邮件附件的表示符号
/** * * @return */ public boolean createconnection(){ try { freeall(); clientmailsocket = new socket(smtpserver, smtpport); printlogger("connect to email server " + smtpserver + " on port " + smtpport,location_to_screen); indata = clientmailsocket.getinputstream(); outdata = clientmailsocket.getoutputstream(); fetchcmdresult();//当首次连接服务器后有返回值,必须取走该返回值,否则后面命令的返回值无法判断 } catch (ioexception e) { return false; } return true; }
public static string response(inputstream in){ byte[] buffer = new byte[1024]; stringbuffer indata = new stringbuffer(); int n = 0; try { n = in.read(buffer); indata.append(new string(buffer, 0, n));