mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-12 17:52:13 +02:00
Update EmailService.java
This commit is contained in:
parent
9504b359cc
commit
bc9af64372
@ -37,8 +37,21 @@ public class EmailService {
|
|||||||
*/
|
*/
|
||||||
@Async
|
@Async
|
||||||
public void sendEmailWithAttachment(Email email) throws MessagingException {
|
public void sendEmailWithAttachment(Email email) throws MessagingException {
|
||||||
ApplicationProperties.Mail mailProperties = applicationProperties.getMail();
|
|
||||||
MultipartFile file = email.getFileInput();
|
MultipartFile file = email.getFileInput();
|
||||||
|
// 1) Validate recipient email address
|
||||||
|
if (email.getTo() == null || email.getTo().trim().isEmpty()) {
|
||||||
|
throw new MessagingException("Invalid Addresses");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) Validate attachment
|
||||||
|
if (file == null
|
||||||
|
|| file.isEmpty()
|
||||||
|
|| file.getOriginalFilename() == null
|
||||||
|
|| file.getOriginalFilename().isEmpty()) {
|
||||||
|
throw new MessagingException("An attachment is required to send the email.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplicationProperties.Mail mailProperties = applicationProperties.getMail();
|
||||||
|
|
||||||
// Creates a MimeMessage to represent the email
|
// Creates a MimeMessage to represent the email
|
||||||
MimeMessage message = mailSender.createMimeMessage();
|
MimeMessage message = mailSender.createMimeMessage();
|
||||||
|
Loading…
Reference in New Issue
Block a user