Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29918

sendSimpeMessage returning 500

$
0
0

I believe i have some endpoint issue with my current controller. I'am trying to send an email using JavaMailSender.

The example below works just fine when sending hardcoded string values.

    @RequestMapping("/sendhc")
    public void sendSimpleMessage() {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo("firstname.lastname@gmail.com");
        message.setSubject("subject");
        message.setText("text");
        emailSender.send(message);
    }

I want to be able to make a request with the values instead of the hardcoded string example as shown above. When posting this i get the NullPointerException.

    @RequestMapping("/send")
    public void sendSimpleMessage(String to, String subject, String text) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo(to);
        message.setSubject(subject);
        message.setText(text);
        emailSender.send(message);
    }

enter image description here

I'm trying POST to localhost:8080/send, with the following values: (as shown in image above)

{ "to":"email@gmail.com", "Subject":"New Errand", "text":"loremloremloremloremlorem" }


Any suggestions of where I could've gone wrong are much appreciated.


Viewing all articles
Browse latest Browse all 29918

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>