Bonjour à tous,
J'ai eu un gros problème quand je réalise une application pour récupérer des mails dans la boite aux lettres. Quand je teste la connexion, Eclipse m'a lancé cette genre de problème(mon adresse de l'hote, login et le mot de passe n'ont pas de soucis):
mon programme est là(normalement il y'a pas de soucis car j'ai testé avec les autres boites. merci beaucoup):javax.mail.MessagingException: Connection dropped by server?;
nested exception is:
java.io.IOException: Connection dropped by server?
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:618)
at javax.mail.Service.connect(Service.java:291)
at Mails.Connexion.<init>(Connexion.java:38)
at Mails.Connexion.main(Connexion.java:68)
Caused by: java.io.IOException: Connection dropped by server?
at com.sun.mail.iap.ResponseInputStream.readResponse(ResponseInputStream.java:111)
at com.sun.mail.iap.Response.<init>(Response.java:91)
at com.sun.mail.imap.protocol.IMAPResponse.<init>(IMAPResponse.java:56)
at com.sun.mail.imap.protocol.IMAPResponse.readResponse(IMAPResponse.java:130)
at com.sun.mail.imap.protocol.IMAPProtocol.readResponse(IMAPProtocol.java:261)
at com.sun.mail.iap.Protocol.<init>(Protocol.java:116)
at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:104)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:585)
... 3 more
Merci beaucoup!!!!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 package Mails; import javax.mail.*; import java.util.*; public class Connexion { private String host = "*********";//l'adresse de l'hote private String username = "corp\\******";//le login private String password = "*******";//le mot de passe private String provider = "imap";//le protocole utilisé private int port=993; //private int port=25; public Folder inbox; public Store store; public Connexion(){ Properties props = new Properties(); try { // Connect to the server Session session = Session.getDefaultInstance(props, null); store = session.getStore(provider); store.connect(host,port, username, password); // Open the folder inbox = store.getFolder("INBOX"); if (inbox == null) { System.out.println("No INBOX"); System.exit(1); } inbox.open(Folder.READ_WRITE); }catch (Exception e) { //System.out.println("Connexion erreur"); e.printStackTrace(); } } //Déconnecter de la boite aux lettres, lancer à la fin de l'application public final void deconexion(){ try{ // Close the connection // but don't remove the messages from the server inbox.close(true); store.close(); }catch(Exception ex){ System.out.println("Connexion erreur"); } } public static void main(String[] args){ //pour tester la connextion Connexion c=null; c=new Connexion();//connecter en créant l'objet c.deconexion(); } }
Partager