Class EmailServiceImplementation

java.lang.Object
app.YUP.externalService.EmailServiceImplementation
All Implemented Interfaces:
EmailService

@Service public class EmailServiceImplementation extends Object implements EmailService
This class implements the EmailService interface and provides the functionality to send emails with or without attachments. It uses Spring's JavaMailSender to send emails. It is annotated with @Service to indicate that it is a Spring service component.
  • Field Details

    • sender

      public String sender
      The sender's email address. This is currently hardcoded to "theyupteam@gmail.com", but in a real application, it would be better to externalize this to a configuration file.
  • Constructor Details

    • EmailServiceImplementation

      public EmailServiceImplementation()
  • Method Details

    • sendMailWithoutAttachment

      public void sendMailWithoutAttachment(EmailDetails details)
      Sends an email without an attachment. This method creates a MimeMessage, sets the sender, recipient, and subject from the provided EmailDetails, and then sends the email using the JavaMailSender.
      Specified by:
      sendMailWithoutAttachment in interface EmailService
      Parameters:
      details - an EmailDetails object containing the details of the email to be sent
      Throws:
      EmailNotSentException - if an error occurs while sending the email
    • sendMailWithAttachment

      public void sendMailWithAttachment(EmailDetails details)
      Sends an email with an attachment. This method creates a MimeMessage, sets the sender, recipient, and subject from the provided EmailDetails, attaches the file specified in the EmailDetails, and then sends the email using the JavaMailSender.
      Specified by:
      sendMailWithAttachment in interface EmailService
      Parameters:
      details - an EmailDetails object containing the details of the email to be sent, including the attachment
      Throws:
      EmailNotSentException - if an error occurs while sending the email