Last active
January 20, 2020 19:43
-
-
Save mrtampan/c01d3fbc11a68545adc1cfd31ff0d618 to your computer and use it in GitHub Desktop.
spring mail senderrrr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Autowired | |
public JavaMailSender emailSender; | |
public void sendSimpleMessage( | |
String to, String subject, String text, String from) { | |
SimpleMailMessage message = new SimpleMailMessage(); | |
message.setTo(to); | |
message.setSubject(subject); | |
message.setText(text); | |
message.setFrom(from); | |
try { | |
emailSender.send(message); | |
}catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
@GetMapping(value="send") | |
@ResponseBody | |
public String kirimEmail() { | |
sendSimpleMessage("[email protected]", "Testing Your sping", "asdadasda", "[email protected]"); | |
return "sukses"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment