Class Email

java.lang.Object
net.bugreaper.modules.email.Email
All Implemented Interfaces:
EmailInt

public class Email extends Object implements EmailInt
Email helper that provides a common API for sending emails via SMTP using Jakarta Mail.

Supports:

  • Simple email sending
  • Fluent builder API for advanced emails
  • Attachments
  • Custom headers (tags)

It is recommended to use a single instance: Email email = Email.getInstance();

Typical usage:


 email.build("Subject", "Body")
      .setFrom("your_email@gmail.com")
      .addTo("my_email@gmail.com")
      .addAttach("file.txt", "tmp/file.txt")
      .addTags("qa")
      .send();
 
Since:
1.0.0
  • Constructor Details

    • Email

      public Email(String host, int port, String username, String password)
      Creates an EmailMailpit helper configured for authenticated SMTP.
      Parameters:
      host - SMTP server host (e.g. smtp.gmail.com)
      port - SMTP port (e.g. 587 for TLS)
      username - SMTP username
      password - SMTP password or app password
    • Email

      public Email(String host, int port)
      Creates an Email helper configured for unauthenticated SMTP.
      Parameters:
      host - SMTP server host (e.g. smtp.gmail.com)
      port - SMTP port (e.g. 587 for TLS)
    • Email

      public Email()
      Constructs a Email client using YAML configuration.

      Loads configuration values from a YAML file.

      Default file: bugreaper.yml

      Custom file: using -DbugreaperEnv=test loads bugreaper-test.yml

       modules:
         email:
           host: localhost
           port: 1025
           auth: true # (optional)
           username: 'user' # (optional)
           password: 'password123' # (optional)
       

      Missing required keys will result in configuration errors. Missing optional keys will fall back to predefined defaults.

      Throws:
      IllegalArgumentException - if the configuration contains invalid values
  • Method Details