Java und Emails

Halo1982

Mitglied
Hallo liebe Community,

momentan suche ich eine Möglichkeit, per Java auf Emails zuzugreifen (am besten auf den Server zugreifen) und diese Emails will ich auch ein Paar Wörter analysieren. Gibt es da eine Möglichkeit?
 
😉 beim nächsten mal einfach vorher probieren.
Viele reagieren auf sowas etwas allergisch und du ersparst dir "komische Antworten" wie meine 🙂
 
Hallo 🙂
seid 2 Tagen versuche ich mir javamail anzueignen aber die Connection geht einfach nicht, egal welches Beispiel aus dem Internet ich nehme (seltsamer Satzbau, aber ich denke man versteht es). Das ist der Code den ich aktuell mit Eclipse verwende:

Java:
    import java.util.Properties; 
    import javax.mail.*; 
    import javax.mail.internet.*; 
     
    public class SendMailSSL { 
     public static void main(String[] args) { 
     
     String to="sonoojaiswal1987@gmail.com";//change accordingly 
     
      //Get the session object 
      Properties props = new Properties(); 
      props.put("mail.smtp.host", "smtp.gmail.com"); 
      props.put("mail.smtp.socketFactory.port", "465"); 
      props.put("mail.smtp.socketFactory.class", 
                "javax.net.ssl.SSLSocketFactory"); 
      props.put("mail.smtp.auth", "true"); 
      props.put("mail.smtp.port", "465"); 
      
      Session session = Session.getDefaultInstance(props, 
       new javax.mail.Authenticator() { 
       protected PasswordAuthentication getPasswordAuthentication() { 
       return new PasswordAuthentication("yourgmailid@gmail.com","password");//change accordingly 
       } 
      }); 
      
      //compose message 
      try { 
       MimeMessage message = new MimeMessage(session); 
       message.setFrom(new InternetAddress("yourgmailid@gmail.com"));//change accordingly 
       message.addRecipient(Message.RecipientType.TO,new InternetAddress(to)); 
       message.setSubject("Hello"); 
       message.setText("Testing......."); 
        
       //send message 
       Transport.send(message); 
     
       System.out.println("message sent successfully"); 
      
      } catch (MessagingException e) {throw new RuntimeException(e);} 
      
     } 
    }

Die Fehlermeldung:
Code:
Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1
    at de.cta.email.SendMailSSL.main(SendMailSSL.java:41)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2042)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)
    at javax.mail.Service.connect(Service.java:386)
    at javax.mail.Service.connect(Service.java:245)
    at javax.mail.Service.connect(Service.java:194)
    at javax.mail.Transport.send0(Transport.java:253)
    at javax.mail.Transport.send(Transport.java:124)
    at de.cta.email.SendMailSSL.main(SendMailSSL.java:37)

Wisst ihr wo der Fehler liegt?
Website: http://www.javatpoint.com/example-of-sending-email-using-java-mail-api-through-gmail-server
 
den link kenne ich, aber wahrscheinlich bin ich zu blöd um es zu verstehen 🙂 Ich weis, das die Zugangsdaten stimmen aber was muss ich jetzt tun?

Das ich die Zugangsdaten auf meine eigenen anpasse, versteht sich von selbst
 

Neue Themen


Zurück
Oben