我用java写了一个发送邮件的程序,提示发送成功,但是发送到的邮箱却收到不邮件?这是为什么
package cn.itcast;
import java.util.Properties;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class Demo1 {
/**
* @param args add by zxx ,Feb 5, 2009
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
Properties props = new Properties();
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.transport.protocol", "smtp");
Session session = Session.getInstance(props);
session.setDebug(true);
Message msg = new MimeMessage(session);
msg.setText("nengshoudaoma");
msg.setFrom(new InternetAddress("haosiweishizhu@sohu.com"));
Transport transport = session.getTransport();
transport.connect("smtp.sina.cn", 25, "haosiweishizhu", "haosiwei");
transport.sendMessage(msg,new Address[]{new InternetAddress("wangzhiqing0327@sohu.com")});
//transport.send(msg,new Address[]{new InternetAddress("itcast_test@sohu.com")});
transport.close();
}
}
运行提示:
DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.sina.cn", port 25, isSSL false
220 irxd5-182.sinamail.sina.com.cn ESMTP
DEBUG SMTP: connected to host "smtp.sina.cn", port: 25
EHLO 59972864974a4a5
250-irxd5-182.sinamail.sina.com.cn
250-8BITMIME
250-SIZE 83886080
250-AUTH PLAIN LOGIN
250 AUTH=PLAIN LOGIN
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "SIZE", arg "83886080"
DEBUG SMTP: Found extension "AUTH", arg "PLAIN LOGIN"
DEBUG SMTP: Found extension "AUTH=PLAIN", arg "LOGIN"
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNlcm5hbWU6
aGFvc2l3ZWlzaGl6aHU=
334 UGFzc3dvcmQ6
aGFvc2l3ZWk=
235 #2.0.0 OK Authenticated
DEBUG SMTP: use8bit false