j'ai utilisé cette fonction pour envoyer un message de type texte

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
 
public class envoyer { 
 
public static void main(String[] args) throws Exception{ 
 
 
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); 
final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; 
// Get a Properties object 
Properties props = System.getProperties(); 
props.setProperty("mail.smtp.host", "smtp.gmail.com"); 
props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY); 
props.setProperty("mail.smtp.socketFactory.fallback", "false"); 
props.setProperty("mail.smtp.port", "465"); 
props.setProperty("mail.smtp.socketFactory.port", "465"); 
props.put("mail.smtps.auth", "true"); 
props.put("mail.debug", "true"); 
props.put("mail.store.protocol", "pop3"); 
props.put("mail.transport.protocol", "smtp"); 
final String username = "boite1";//sans @gmail.com 
final String password = "passe"; 
 
Session mailSession = Session.getDefaultInstance(props, new Authenticator() 
{protected PasswordAuthentication getPasswordAuthentication() 
{ return new PasswordAuthentication(username, password); }}); 
 
 
// -- Create a new message -- 
Message msg = new MimeMessage(mailSession); 
//System.out.println("mailSession"); 
 
// -- Set the FROM and TO fields -- 
msg.setFrom(new InternetAddress("boite1@gmail.com")); 
// System.out.println("mailSession"); 
msg.setRecipients(Message.RecipientType.TO, 
InternetAddress.parse("boite2@gmail.com",false)); 
//System.out.println("mailSession"); 
msg.setSubject("Hello"); 
msg.setText("How are you"); 
msg.setSentDate(new Date()); 
//System.out.println("mailSession"); 
// Transport.send(msg); 
 
 
// Transport.send(msg); 
 
System.out.println("Message sent."); 
} 
}

elle m'affiche Message sent. mais je ne trouve rien dans ma boite , je ne vois pas ou est le probleme