Mailable class abstract

Base class for mailable objects.

Mailables provide a clean, object-oriented way to build emails. Extend this class and implement the build() method to define your email.

Example:

class WelcomeMail extends Mailable {
  final User user;

  WelcomeMail(this.user);

  @override
  Future<void> build(MailerInterface mailer) async {
    await mailer
        .to(user.email)
        .subject('Welcome to ${user.name}!')
        .view('emails.welcome', {'user': user});
  }
}

// Usage:
await Mail.send(WelcomeMail(user));

Constructors

Mailable()

Properties

displayName String
The display name for this mailable (used in logs).
no setter
hashCode int
The hash code for this object.
no setterinherited
queueConnection String?
The queue connection to use.
no setter
queueDelay Duration?
The delay before sending when queued.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldQueue bool
Determines if this mailable should be queued.
no setter

Methods

afterSend() Future<void>
Hook called after the mailable is sent successfully.
beforeSend() Future<void>
Hook called before the mailable is sent.
build(MailerInterface mailer) Future<void>
Builds the email message.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onError(dynamic error, StackTrace stackTrace) Future<void>
Hook called if sending fails.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited