Class MailSender

java.lang.Object
com.axelor.mail.MailSender

public final class MailSender extends Object
The MailSender provides features to send mails.
  • Constructor Details

    • MailSender

      public MailSender(MailAccount account)
      Create a new MailSender with the given account.
      Parameters:
      account - the account to use
  • Method Details

    • compose

      public MailBuilder compose()
      Compose a new mail message.
      Returns:
      a MailBuilder instance.
    • send

      public void send(jakarta.mail.Message message) throws jakarta.mail.MessagingException
      Send a mail message.
      Parameters:
      message - the message to sent
      Throws:
      jakarta.mail.MessagingException - if the message could not be sent
      See Also:
      • Transport.send(Message)
    • send

      public void send(String subject, String text, String... recipients) throws jakarta.mail.MessagingException
      Send a simple text message to the given recipients.

      For better options, use compose() method to compose a message using MailBuilder which can be retrieved or sent directly with MailBuilder.build() or MailBuilder.send() methods.
      Parameters:
      subject - the message subject
      text - the message text
      recipients - list of recipients
      Throws:
      jakarta.mail.MessagingException - if the message could not be sent