用Java编程实现SMTP服务器功能(5)

来源:asp之家 时间:2010-03-13 18:46:00 

mailSendFrame.java源程序代码如下:

import java.awt.*;
import java.awt.event.*;
public class mailSendFrame extends Frame {
smtpMail mailSender=new smtpMail();
Panel panelMain = new Panel();
Panel panelUp = new Panel();
Panel panel3 = new Panel();
Panel panel4 = new Panel();
Panel panel6 = new Panel();
Panel panel7 = new Panel();
TextField txtServer = new TextField();
TextField txtTo = new TextField();
TextField txtFrom = new TextField();
TextField txtSubject = new TextField();
Panel panel8 = new Panel();
Label lblFile = new Label();
Button cmdBrowse = new Button();
Panel panelDown = new Panel();
TextArea txtMail = new TextArea();
Panel panel10 = new Panel();
Button cmdSend = new Button();
Button cmdExit = new Button();
private FileDialog openFileDialog
= new FileDialog(this,"打开文件",FileDialog.LOAD);
public mailSendFrame() {
try {
Init();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
mailSendFrame mailSendFrame = new mailSendFrame();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = mailSendFrame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
mailSendFrame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
mailSendFrame.setVisible(true);
mailSendFrame.show();
}
private void Init() throws Exception {
this.setLayout(new BorderLayout());
panelMain.setLayout(new GridLayout(2,1));
panelUp.setLayout(new GridLayout(6,1));
panel3.setLayout(new FlowLayout());
this.setVisible(true);
.......
.......
//smtpMail.java 的源代码
import java.io.*;
import java.net.Socket;
import java.util.*;
public class smtpMail{
private boolean sendConf=false;
public static final int OK = 1;
public static final int ERROR = 0;
private static final String TEXT = "1";
private static final String TFILE = "2";
private static final String BFILE = "3";
private static final String CPR = "Java 1.0";
private static final String MAILER = "X-Mailer";
private static final int BUFFER_SIZE = 48;
private String DELIMETER;
private String SEPARATOR;
private static final int HOW_LONG = 6;
private static final char SMTP_ERROR_CODE1 = 52;
private static final char SMTP_ERROR_CODE2 = 53;
private static final int fillchar = 61;
private static final String cvt =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
private Socket mailSocket;
private BufferedReader recv;
private PrintWriter send;
private String from;
private String to;
private String domain;
private Vector x_set;
private Vector body;
private Vector attach;
public smtpMail(){
DELIMETER = "";
SEPARATOR = "";
mailSocket = null;
recv = null;
send = null;
from = "";
to = "";
domain = "";
x_set = new Vector();
body = new Vector();
attach = new Vector();
DELIMETER = getId();
SEPARATOR = System.getProperty("file.separator");
}
.........
.........

标签:smtp服务器,java服务器
0
投稿

猜你喜欢

  • 五个途径写一篇符合网站优化的文章

    2009-01-19 12:41:00
  • 在Linux环境中如何配置WU-FTP服务器

    2009-12-23 19:19:00
  • 用MDaemon搭建邮件服务器(中)

    2007-11-21 13:57:00
  • 腾讯成立中国互联网首家研究院

    2007-10-18 12:35:00
  • 详解Linux下出现permission denied的解决办法

    2023-06-13 14:11:14
  • linux find命令将查找到的文件批量删除方法

    2023-08-29 00:53:11
  • 在AdSense 帐户中使用谷歌分析工具

    2008-10-31 12:10:00
  • 浅谈中小站长站点运营推广

    2008-04-02 11:47:00
  • 关于Apache服务器如何实现用户验证

    2010-05-08 18:10:00
  • Discuz与UCenter同步删除用户

    2009-08-27 13:00:00
  • 宝塔Linux面板之好用免费的中文Linux VPS主机控制面板适合快速建站

    2023-07-12 05:21:58
  • 盘点五个最具有中国风土文化特色的网页游戏

    2009-10-22 09:52:00
  • 解决Linux服务器下误删除文件问题!

    2008-10-13 18:37:00
  • Windows 2003 Server安全配置图文教程

    2010-03-24 18:56:00
  • 李开复:“google网页快照正在解决中”

    2007-09-26 11:56:00
  • WAP图片站的六点分析

    2008-10-19 16:14:00
  • 苹果将积极为自己辩护 反击诺基亚侵权诉讼

    2009-10-30 07:54:00
  • 谷歌网站管理员详解:如何使用robots.txt

    2009-01-23 14:24:00
  • Linux7.7设置交换分区SWAP的方法

    2023-10-16 23:49:41
  • eWeek列举不为外界所知的Google10件事

    2009-10-15 11:17:00
  • asp之家 网站运营 m.aspxhome.com