java.lang.Object
com.irurueta.authserver.authorization.infrastructure.mail.SmtpAccountMailer
All Implemented Interfaces:
AccountMailer

public class SmtpAccountMailer extends Object implements AccountMailer
AccountMailer that sends plain-text messages through SMTP. Subject and body come from a MessageSource resolved with the explicitly configured locale, never the platform's default. A delivery failure is reported as an AccountMailException that carries neither the address nor the token, so the calling use case rolls back whatever it stored for the message.
  • Field Details

    • VERIFICATION

      static final String VERIFICATION
      Message key prefix of the e-mail verification message.
      See Also:
    • ALREADY_REGISTERED

      static final String ALREADY_REGISTERED
      Message key prefix of the already-registered message.
      See Also:
    • RESET

      static final String RESET
      Message key prefix of the reset message.
      See Also:
    • VERIFY_PATH

      static final String VERIFY_PATH
      Path of the verification endpoint.
      See Also:
    • RESET_PATH

      static final String RESET_PATH
      Path of the page that lets the user choose a new secret.
      See Also:
    • mailSender

      private final org.springframework.mail.javamail.JavaMailSender mailSender
      Sends the messages.
    • messageSource

      private final org.springframework.context.MessageSource messageSource
      Source of the subjects and bodies.
    • properties

      private final MailProperties properties
      Sender, base URL and locale.
  • Constructor Details

    • SmtpAccountMailer

      public SmtpAccountMailer()
  • Method Details

    • sendEmailVerification

      public void sendEmailVerification(String email, String token)
      Specified by:
      sendEmailVerification in interface AccountMailer
    • sendAlreadyRegistered

      public void sendAlreadyRegistered(String email)
      Specified by:
      sendAlreadyRegistered in interface AccountMailer
    • sendPasswordReset

      public void sendPasswordReset(String email, String token)
      Specified by:
      sendPasswordReset in interface AccountMailer
    • send

      private void send(String email, String prefix, String link)
      Builds and sends one message.
      Parameters:
      email - recipient address.
      prefix - message key prefix; .subject and .body are appended.
      link - link inserted as the first argument of the body.
      Throws:
      AccountMailException - if the message cannot be delivered.
    • encode

      private static String encode(String value)
      Encodes a value for a query parameter.
      Parameters:
      value - value to encode.
      Returns:
      the encoded value.