package fr.organizee.controller; import fr.organizee.model.Mail; import fr.organizee.service.SendMailService; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.mail.MessagingException; @RestController @RequestMapping("/mail") public class MailController { SendMailService service; public MailController(SendMailService service) { this.service = service; } @PostMapping("/send") public ResponseEntity sendMail(@RequestBody Mail mail) { service.sendMail(mail); return new ResponseEntity<>("Email Sent successfully", HttpStatus.OK); } @PostMapping("/html") public ResponseEntity sendMailHTML(@RequestBody Mail mail) throws MessagingException { service.sendMailHTML(mail); return new ResponseEntity<>("HTML mail sent successfully", HttpStatus.OK); } @PostMapping("/attachment") public ResponseEntity sendAttachmentEmail(@RequestBody Mail mail) throws MessagingException { service.sendMailWithAttachments(mail); return new ResponseEntity<>("Attachment mail sent successfully", HttpStatus.OK); } }