MailManager class

Manages multiple mail drivers/transports.

Allows switching between different mail services (SMTP, SES, Mailgun, etc.) and provides a convenient API for sending emails.

Example:

final mailManager = MailManager(config, queueManager);

// Use default mailer
await mailManager.to('user@example.com')
    .subject('Hello')
    .text('Hello World')
    .send();

// Use specific mailer
await mailManager.mailer('ses')
    .to('user@example.com')
    .subject('Hello')
    .send();
Implemented types

Constructors

MailManager(ConfigInterface _config, {QueueManager? queueManager})

Properties

availableTransports List<String>
Gets list of registered transport names.
no setter
defaultMailer MailerInterface
Gets the default mailer.
no setter
driverName String
Gets the underlying transport/driver name.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

attach(String path, {String? name, String? mimeType}) MailerInterface
Attaches a file to the email.
override
attachData(List<int> data, String name, {String? mimeType}) MailerInterface
Attaches raw data as a file.
override
bcc(dynamic addresses) MailerInterface
Sets the BCC (Blind Carbon Copy) recipient(s).
override
cc(dynamic addresses) MailerInterface
Sets the CC (Carbon Copy) recipient(s).
override
clearMailers() → void
Clears all cached mailers (useful for testing).
embed(String path, String cid) MailerInterface
Embeds an inline image in the email.
override
from(String address, [String? name]) MailerInterface
Sets the email sender (from address).
override
Sets a custom header.
override
html(String content) MailerInterface
Sets the HTML body of the email.
override
mailer([String? name]) MailerInterface
Gets a mailer instance by name.
message() MailMessageInterface
Creates a new message builder.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
priority(int priority) MailerInterface
Sets the email priority.
override
queue([Duration? delay]) Future<void>
Queues the email for asynchronous sending.
override
queueMailable(Mailable mailable, [Duration? delay]) Future<void>
Queues a Mailable instance.
override
registerTransport(String name, TransportInterface transport) → void
Registers a mail transport driver.
replyTo(String address, [String? name]) MailerInterface
Sets the reply-to address.
override
send() Future<bool>
Sends the email immediately.
override
sendMailable(Mailable mailable) Future<bool>
Sends a Mailable instance.
override
subject(String subject) MailerInterface
Sets the email subject.
override
testTransport([String? name]) Future<bool>
Tests a mail transport connection.
text(String content) MailerInterface
Sets the plain text body of the email.
override
to(dynamic addresses) MailerInterface
Sets the recipient(s) of the email.
override
toString() String
A string representation of this object.
inherited
view(String viewName, [Map<String, dynamic>? data]) Future<MailerInterface>
Renders a view template for the email body.
override

Operators

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