日期:2014-05-18  浏览次数:20915 次

javamail发送邮件成功 但是却接收不到邮件?
我用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
MAIL FROM:<haosiweishizhu@sohu.com>
250 sender <haosiweishizhu@sohu.com> ok
RCPT TO:<wangzhiqing0327@sohu.com>
250 recipient <wangzhiqing0327@sohu.com> ok
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   wangzhiqing0327@sohu.com
DATA
354 go ahead
From: haosiweishizhu@sohu.com
Message-ID: <24212202.01317206893437.JavaMail.Administrator@59972864974a4a5>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

nengshoudaoma
.
250 ok:  Message 957325150 accepted
QUIT
221 irxd5-182.sinamail.sina.com.cn
------解决方案--------------------