Skip to content

Instantly share code, notes, and snippets.

@larsgroeber
Last active April 6, 2020 17:34
Show Gist options
  • Save larsgroeber/3bd2cf3bcd4149a7b628c7e1e85c7ed2 to your computer and use it in GitHub Desktop.
Save larsgroeber/3bd2cf3bcd4149a7b628c7e1e85c7ed2 to your computer and use it in GitHub Desktop.
@RestController
@RequestMapping("/email")
public class EmailApiController {
private final EmailService emailService;
public EmailApiController(EmailService emailService) {
this.emailService = emailService;
}
@RequestMapping(method = RequestMethod.POST, value = "/sendMail", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity sendMail(
@RequestParam("subject") String subject,
@RequestParam("toMail") String toMail,
@RequestParam("body") String body) {
SendMailRequest request = SendMailRequest.builder().subject(subject)
.recipient(Contact.builder().address(toMail).build())
.body(body)
.build();
emailService.sendMail(request);
return ResponseEntity.noContent().build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment