我这有代码如下:
import java.util.*; 
import java.io.*; 
import javax.mail.*; 
import javax.mail.internet.*; 
import javax.activation.*; 
public class SendSimpleMail { 
file://msgText是信件的正文,共有两行 
static String msgText = "Dear Mr.FangZhou\nI’m a reader of your net!" 
file://从命令行中读入三个参数,分别为smtpHost,from,to 
public static void main(String args[]) 
throws Exception{ 
if (args.length != 3) { 
System.out.println("usage: java SendSimpleMail "); 
return; 

String smtpHost=args[0];//SMTP服务器名 
String from=args[1];//发信人地址 
String to =args[2];//收信人地址 
// 创建properties对象 
Properties props = new Properties(); 
file://创建邮件服务器 
props.put("mail.smtp.host", smtpHost); 
file://取得默认的Session 
Session session = Session.getDefaultInstance(props, null); 
// 创建一条信息,并定义发信人地址和收信人地址 
MimeMessage message = new MimeMessage(session); 
message.setFrom(new InternetAddress(from)); 
InternetAddress[] address = {new InternetAddress(to)}; 
message.setRecipients(Message.RecipientType.TO, address); 
message.setSubject("Hello,FangZhou");//设定主题 
message.setSentDate(new Date());//设定发送时间 
message.setText(msgText);//把前面定义的msgText中的文字设定为邮件正文的内容 
file://发送邮件 
Transport.send(message); } 

你也可以到www.google.com上去找