0

I want to testing send mail using JavaMailSender,the code work fine but when I setting my pc time to the past it throw this exception.

Could not convert socket to TLS

Here is my code

            MimeMessageHelper message = new MimeMessageHelper(mimeMessage, "UTF-8");
            message.setSubject(subject);
            message.setFrom(config.getMailFrom());
            message.setTo(recipientEmail);
            String htmlContent = templateEngine.process("email.html", ctx);
            message.setText(htmlContent, true );
            mailSender.send(mimeMessage);
        catch (Exception e) {
            throw new Exception();
        }           

I try to turn off the window defender but it didn't work.

My pc does not have any antivirus software or anything like protection software.It's some kind of JavaMailSender protection or a bug?

EasyU
  • 11
  • 1
  • 1
    please edit your question to explain what you mean by "system time is past time". – starball Sep 05 '22 at 08:03
  • 1
    Please provide enough code so others can better understand or reproduce the problem. – Community Sep 05 '22 at 08:03
  • What are you actually trying to achieve? Are you trying to send an email that looks like it was sent from the past? Does your code work when the time is set correctly? Also please show us a little more from the exception, there's a "Nested exception" portion there, somewhere. – Petr Janeček Sep 05 '22 at 08:24
  • 1
    basically yes,when the time is set correctly the code work fine but when I set my system time to 2021 then try to send an email,it throw the exception – EasyU Sep 05 '22 at 08:27
  • 1
    This is a wild guess without more testing and/or the full exception, but is it possible that the certificate of the server has been set to be valid _after_ your "current" system time? That would basically mean your computer thinks it talks to a fraudulent server which does not have a valid certificate. Try looking at the target cert, and/or move the time closer to today. Does it work when it's from yesterday? Does it work a month back? – Petr Janeček Sep 05 '22 at 08:32
  • it work when i change system to yesterday and a month ago, but when it is 2 month or further it not working nested exception is javax.mail.MessagingException – EasyU Sep 05 '22 at 08:39

0 Answers0