你的stmp需要验证
props.put("mail.smtp.auth","true"); 
ession = Session.getDefaultInstance(props, 第二个参数为PasswordAuthentication对像);

解决方案 »

  1.   

    各位,我的一个jsp+javabean的web系统,在我们这边的运行时一切正常,在客户那边运行时,发送邮件的功能常报这样的错误:
    javax.mail.SendFailedException: 530 delivery not allowed to non-local recipient, try authenticating
    只要我发送的不是与发送邮件服务器同一个服务器的email地址,就报这样的错误。
    但是,我在outlook中,这个发送邮件的账号是可以发给任何email地址的。
    请问,这是什么原因,是邮件服务器上有这样一个设置吗?还是我的程序有问题?
    我的程序中使用的发送email的方法是这个:transport.sendMessage( mimeMsg, mimeMsg.getAllRecipients() );
      

  2.   

    这是俺前个项目用到JMail的部分代码,运行没有问题。你自己比较一下吧。
          
          String sendServer="***.**.*.***";
          Properties props = System.getProperties();
          props.put("mail.smtp.auth", "true");
          props.put("mail.smtp.host", sendServer);
          auth.setUsername(aUsername);
          auth.setPassword(aPassword);
          Session session = Session.getDefaultInstance(props, auth);      try {
             MimeMessage msg = new MimeMessage(session);
             /*设置邮件内容
             */         Transport transport = session.getTransport("smtp");
             transport.connect(sendServer, aUsername, aPassword);         transport.sendMessage(msg, msg.getAllRecipients());
             transport.close();
          }
          catch (MessagingException mex) {
             throw new Exception("发送邮件失败");
          }