我写的源程序如下:
package demo;
import java.io.*;
//import java.util.*;
import sun.net.smtp.*;
//import sun.net.*;
public class TestMail {
public TestMail(){ }
public void send(String from, String to, String subject, String message){
try {
SmtpClient client = new SmtpClient("smtp.163.com");
System.out.println( "*** sendEMail : new SmtpClient");
client.from(from);
System.out.println( "*** sendEMail : client.from( from )");
client.to(to);
System.out.println( "*** sendEMail : client.to( to )");
PrintStream ps = client.startMessage();
System.out.println( "*** sendEMail : client.startMessage()");
ps.println("Subject: " + "hi");
ps.println();
System.out.println( "*** sendEMail : ps.println()");
ps.println(message);
System.out.println( "*** sendEMail : ps.println(message )");
client.closeServer();
System.out.println( "*** sendEMail : Sending sucssesful!");
}
catch( Exception ex ) {
System.out.println( "--- sendEMail : Sending failed: " + ex.getMessage() );
}
}
public static void main(String args[]){
TestMail mymail = new TestMail();
String subject = "Send email from administration dls";
String message = "ni hao!";
mymail.send("donesheng123@163.com","donsheng123@163.net",subject,message);
}
}
运行后输出以下信息:
*** sendEMail : new SmtpClient
--- sendEMail : Sending failed: 553 authentication is required,smtp1,wKjRC7BrLQmyut5GsdENKg==.22247S2 1189001906
是不是smtp是需要验证的才出现以上结果?麻烦各位看一下,急盼回复,不胜感激!
[此贴子已经被作者于2007-9-5 22:32:03编辑过]