您的位置:软件 > 开发者网络 > 开发工具 > Java > 正文
用Java实现SMTP服务器
[文章信息]
作者:petery
时间:2003-07-25
出处:论坛
责任编辑:方舟
[文章导读]
本文以SMTP发送电子邮件为例讲解怎样用Java 实现SMTP 服务器应用功能...
advertisement
热点推荐
· 天极网软件频道改版调查
· 在ASP.NET程序中创建唯一序号
· 用JVM工具接口创建调试和分析代理
· Win 2000如何安装配置防火墙
· 防范Windows消息钩子的侵入
[正文]

上一页  1 2 3 4 5  

  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");
}
.........
.........


上一页  1 2 3 4 5  

·"WAP天极之IT新闻资讯,50万元等你拿"    ·天极WAP之游戏狂图,50万元等你下载


发表评论推荐给朋友我想参加相关培训打印我对此感兴趣订阅电子杂志
相关内容阅读排行榜
  • 用Java实现FTP服务器
  • JBuilder7+Delphi6写CORBA体验
  • Java布局管理器在现实工程中的应用
  • Java开发中的线程安全选择与Swing
  • 用Java构造自己的媒体播放器
  • 主板超频特色技术GIGA技嘉篇
  • Win 2000如何安装配置防火墙
  • 防范Windows消息钩子的侵入
  • 性价比之选 AGP显卡的告别秀
  • 大学校园生活之聊天也疯狂
  • Fireworks制作GIF动画Banner
  • 金山打击外挂 遭网络游戏玩家起诉
  • 完全公测《开天》掀起滔滔巨浪
  • Advertisement