springemailovh

Java Spring app mail Gmail OK but not working with OVH


I built a Java Spring app that send mail through an OVH configuration, where I have a domain name and a mail service. To test on my localhost, I also tried to send mail with a Gmail configuration, which is working well. With the OVH configuration, I don't have any issue, except that I never receive the mail.

Do you have any advice to look at and that could cause the OVH service to be unsuccessful ?

Here is my configuration :

spring:
  mail:
    host: ssl0.ovh.net #smtp.gmail.com
    port: 587
    username: mail@domain-ovh.fr #mail@gmail.com
    password: password
    properties:
      mail:
        transport.protocol: smtp
        smtp:
          auth: true
          starttls:
            enable: true
            required: true
    test-connection: true

Thanks !


Solution

  • So after many hours looking for configuration on OVH website, I tried a node app... And it worked well. So the issue is in my java application.

    I took a look at my parameters, and within my message I didn't fill all the informations, the recipient was missing. Apparently it doesn't bother gmail, but with OVH it won't work.

    Here is the minimalist code to send the mail :

    public void send() {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom("mail@domain-ovh.fr");
        message.setTo("dest@mail.com");
        message.setSubject("Subject");
        message.setText("Body");
        mailSender.send(message);
    }
    

    And the configuration on my question is correct.