Skip to content

Instantly share code, notes, and snippets.

@mrtampan
Last active January 20, 2020 19:43
Show Gist options
  • Save mrtampan/c01d3fbc11a68545adc1cfd31ff0d618 to your computer and use it in GitHub Desktop.
Save mrtampan/c01d3fbc11a68545adc1cfd31ff0d618 to your computer and use it in GitHub Desktop.
spring mail senderrrr
@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