Chinaunix首页 | 论坛 | 博客
  • 博客访问: 14210
  • 博文数量: 12
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 125
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-19 15:05
文章分类

全部博文(12)

文章存档

2011年(1)

2009年(11)

我的朋友
最近访客

分类: Java

2009-08-20 12:00:46

package com.wm.affnet.util ;
import java.io.*;
import java.net.*;
public class SendEmail {
   public static void messageSend (String senderId, String receiverId, String subjectText, String emailText)
   {
     Socket sock = null ;
     BufferedReader dis = null;
     PrintStream ps = null;
     try
     {
     InetAddress in = InetAddress.getByName(Constants.SMTP_SERVER);
     sock = new Socket(in, Constants.SMTP_PORT);
     dis = new BufferedReader( new InputStreamReader(sock.getInputStream()));
     ps = new PrintStream( sock.getOutputStream());
     ps.println("mail from: " + senderId);
     System.out.println( dis.readLine() );
     ps.println("rcpt to: " + receiverId);
     System.out.println( dis.readLine() );
     ps.println("data");
     ps.println("Subject: " + subjectText);
     System.out.println( dis.readLine() );
     ps.println(emailText);
     ps.println(".");
     System.out.println( dis.readLine() );
     ps.flush();
     sock.close();
     }
     catch(IOException e) {
        e.printStackTrace() ;
     }
     finally {
        try {
           ps.flush() ;
           sock.close() ;
        }
        catch(IOException e) {
           e.printStackTrace() ;
        }
     }
   }
}
阅读(389) | 评论(0) | 转发(0) |
0

上一篇:log

下一篇:department and catagory

给主人留下些什么吧!~~