MessagingException發郵件異常

一段發郵件的代碼,卻總報下面這個異常,到底是什么原因啊?

javax.mail.MessagingException: 553 sorry, The sender of local domains must authentication

public void send(ServletContext application) throws Exception  {
    MimeMessage msg = null;
    Multipart oMultipart_ = null;

      Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

      // 若要密? ?user ?定一? admin emissuper
      PasswordAuthentication password = new PasswordAuthentication(System.getProperty("mail.smtp.user"), System.getProperty("mail.smtp.password"));
    try {
        // Get a Session object
        Properties props = System.getProperties();
         props.put("mail.smtp.host", System.getProperty("mail.smtp.host"));
         props.put("mail.smtp.auth", "true");
        Session session =  (props == null)                          // [1165 ] merlin start
            ?  Session.getDefaultInstance(System.getProperties(),
                new Authenticator() {
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication(System.getProperty("mail.smtp.user"), System.getProperty("mail.smtp.password"));
                    }
                })
            : Session.getDefaultInstance(props, null);                 // [1165 ] merlin end

//        session.setPasswordAuthentication(new URLName(System.getProperty("mail.smtp.host")), password);

        msg = new MimeMessage(session);


        if (From_ != null)
            msg.setFrom(From_);
        else
            msg.setFrom();

        if ( To_ == null )
          throw new Exception("unable to send null recipient");
        msg.setRecipients(Message.RecipientType.TO,To_);

        if (CC_ != null)        {
            msg.setRecipients(Message.RecipientType.CC,CC_);
        }



        if( sSubject_ != null )

        {

            msg.setSubject(sSubject_);

        }


       oMultipart_ = new MimeMultipart();

       MimeBodyPart _oBody = new MimeBodyPart();
        _oBody.setContent(sBuf_.toString(),"text/html;charset=" + INTERNET_ENCODING);
        oMultipart_.addBodyPart(_oBody);

        if( sAttachment_ != null )   {
            for(int i=0;i<sAttachment_.size();i++){
            FileDataSource _fds = new FileDataSource(sAttachment_.get(i).toString());

            MimeBodyPart _oAttach= new MimeBodyPart();

            DataHandler _dh = new DataHandler(_fds);

            _oAttach.setDataHandler(_dh);
            _oAttach.setFileName(MimeUtility.encodeWord(_fds.getName()));
            oMultipart_.addBodyPart(_oAttach);
            }
        }

        msg.setContent(oMultipart_);
        msg.saveChanges();

        msg.setHeader("X-Mailer", "javamail_1.3.2");
    //    msg.setDataHandler(new DataHandler(
    //      new ByteArrayDataSource(sBuf_.toString(), "text/html;charset=" + INTERNET_ENCODING)));
        msg.setSentDate(new Date());
        // before send , log it to system...
        if( application != null )        {
          // send to the mail queue
          emisMailQueue.getInstance(application).add(msg);
        } else {
          // send it right now
        Transport transport = session.getTransport("smtp");
        transport.connect(System.getProperty("mail.smtp.host"),
          System.getProperty("mail.smtp.user"),
          System.getProperty("mail.smtp.password"));

        transport.sendMessage(msg, msg.getAllRecipients());//報錯的位置
        transport.close();
//          Transport.send(msg);
        }
    } catch (Exception ignore) {
        ignore.printStackTrace();
       if( application != null )  {
         try {
           emisTracer.get(application).warning(this,ignore);
         } catch (Exception ignore1) {}
       }
       throw ignore;
    } finally {
       // free object reference
       msg = null;
       From_ = null;
       To_ = null;
       CC_ = null;
       sSubject_ = null;
       sAttachment_ = null;
    }
  }

 
請各位幫幫忙啊!

你可能感兴趣的:(exception)