javax.E-mail.SendFailedException: Ungültige Adressen (Beim Versuch zu senden emal mit Rediffmail)

Diesem Programm versucht, E-Mails senden, durch die erste Verbindung zu smtp.rediffmail.com . Es gibt keine compile-Zeit-Fehler oder compile-Zeit Ausnahme.Aber als ich versuche, das folgende Programm ausführen, erzeugt es die folgende Ausnahme.

javax.E-mail.SendFailedException: Ungültige Adressen;
nested exception is:
com.Sonne.E-mail.smtp.SMTPAddressFailedException: 421 Autorisierung fehlgeschlagen: bitte authentifizieren
dabei erhalten Nachricht zuerst

Ich kann nicht herausfinden, was die Ausnahme ist und warum bekomme ich diese exception .

Hier ist das vollständige Programm.In diesem habe ich versucht TLS Verbindung mit rediffmail server.

import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;

class rediff {
   public static void main(String args[]) {
      Properties props = new Properties();
      props.put("mail.smtp.host", "smtp.rediffmail.com");
      props.put("mail.stmp.user", "from");

      //To use TLS
      props.put("mail.smtp.auth", "true");
      props.put("mail.smtp.starttls.enable", "true");
      props.put("mail.smtp.password", "password");

      Session session = Session.getDefaultInstance(props, new Authenticator() {
        @Override
            protected PasswordAuthentication getPasswordAuthentication() {
               String username = "from";
               String password = "password";
                return new PasswordAuthentication("from", "password");
            }
      });
       String to = "[email protected]";
       String from = "[email protected]";
       String subject = "Testing...";
       MimeMessage msg = new MimeMessage(session);
         try {
           msg.setFrom(new InternetAddress(from));
           msg.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(to));
           msg.setSubject(subject);
           msg.setText("rediff program working...!");
           Transport transport = session.getTransport("smtp");
           transport.send(msg);
           System.out.println("fine!!");
         }   catch(Exception exc) {
                 System.out.println(exc);
              }
   }
}

Warum erhalte ich diese exception ?

InformationsquelleAutor Suhail Gupta | 2011-07-09
Schreibe einen Kommentar