javaMail的问题---高分求救(困扰我几天几夜了) ( 积分: 200 )

  • 主题发起人 chinazxy2008
  • 开始时间
C

chinazxy2008

Unregistered / Unconfirmed
GUEST, unregistred user!
//发邮件
public boolean sendEmail(String to,String subject,String content) {
String host="smtp.163.com";//mail.thinkrev.com
String user="zxyongweb";
String password="zxyongdb";
String from = "zxyongweb@163.com";

Properties props = new Properties();
props.put("mail.smtp.starttls.enable", "true");

props.put("mail.smtp.host", host);//指定SMTP服务器
props.put("mail.transpost.protocol","smtp");
props.put("mail.smtp.class", "com.sun.mail.smtp.SMTPTransport");
props.put("mail.smtp.auth", "true");//指定是否需要SMTP验证
try
{
Session mailSession = Session.getDefaultInstance(props,new Authen
ticator() {
public PasswordAuthen
tication getPasswordAuthen
tication() {
return new PasswordAuthen
tication("zxyongweb", "zxyongdb");
}
});
mailSession.setDebug(true);//是否在控制台显示debug信息
Message message=new MimeMessage(mailSession);
message.setFrom(new InternetAddress(from));//发件人
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));//收件人
message.setSubject(subject);//邮件主题
message.setText(content);//邮件内容
message.saveChanges();
Transport transport = mailSession.getTransport("smtp");
transport.connect(host, user, password);
log.error("开始发送:");
transport.sendMessage(message, message.getAllRecipients());
transport.close();
}catch(Exception e)
{
log.error("发邮件失败:"+e);
System.out.println(e);
return false;
}
log.error("开始成功:");
return true;
}
结果报错
javax.mail.MessagingException: 502 Error: command not implemented
 
在新的一年里遇到这个问题就这么辣手,再得不得解决答案,我不知道是坚持还是该放弃
 
这个问题可能是你的smtp服务器有问题
按照下面说的,先测试一下smtp服务器
http://support.microsoft.com/?kbid=153119
另外smtp.163.com这个服务器好像是有点问题。你可以换个服务器在测试一下。如果可以,用gmail的测试一下。
 
我碰到的问题更邪,报错跟你的一样,但在我的电脑上没问题,在客户电脑上就报错,烦
 
顶部