Bonjour, j'ai une adresse mail lié à mon domaine avec un mxplan d'ovh, je veux utiliser l'envoie de mail en java via cette adresse en ssl, mais cela ne marche qu'avec le port 25, ovh précise qu'il faut utiliser le port 465 pour du ssl, voici mon code :
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
    public SendMail() {
        super();
        Properties properties = new Properties();
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.host", "ssl0.ovh.net");
        properties.put("mail.smtp.port", "465");
        //properties.put("mail.smtp.starttls.enable", "true");
        properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        //properties.put("mail.debug", "true");
 
        //sess = Session.getDefaultInstance(properties, null);
        sess = Session.getInstance(properties, new Authenticator() {
            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(Datas.NOREPLY, Datas.PWDNOREPLY);
            }
        });
    }
 
    public void sendMessage() throws MessagingException, UnsupportedEncodingException {
        Transport transport=sess.getTransport();
        Message message = new MimeMessage(sess);
        message.setFrom(new InternetAddress("noreply@xxxxx.xxx", "Site web"));
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(destinat));
        message.setSubject(subject);
        message.setContent(content, "text/html; charset=UTF-8");
        message.setHeader("Content-Type", "text/html; charset=\"UTF-8\"");
        transport.connect();
        transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
        transport.close();
    }
avec le port 465 ça bloque au niveau de la ligne : transport.connect();

Merci.