class MailService (View source)

Methods

__construct(ConfigurationManager $config, LoggerInterface|null $logger = null)

No description

bool
sendMail(string $to, string $subject, string $body, string $plainBody = '', array $headers = [])

Send an email using the configured mail transport

bool
sendNewAccountEmail(string $to, string $username, string $password, string $fullname = '')

Send a new account email with login credentials

bool
canConnectToMailServer(string $host, int $port)

Verify that we can connect to the mail server This tests basic connectivity before attempting to send mail

bool
isMailConfigurationValid()

Verify mail configuration is valid before attempting to send

Details

__construct(ConfigurationManager $config, LoggerInterface|null $logger = null)

No description

Parameters

ConfigurationManager $config
LoggerInterface|null $logger

bool sendMail(string $to, string $subject, string $body, string $plainBody = '', array $headers = [])

Send an email using the configured mail transport

Parameters

string $to

Recipient email address

string $subject

Email subject

string $body

Email body (HTML)

string $plainBody

Email body (plain text, optional)

array $headers

Additional headers (optional)

Return Value

bool

True if email was sent successfully, false otherwise

bool sendNewAccountEmail(string $to, string $username, string $password, string $fullname = '')

Send a new account email with login credentials

Parameters

string $to

Recipient email address

string $username

User's username

string $password

User's password

string $fullname

User's full name (optional)

Return Value

bool

True if email was sent successfully, false otherwise

Exceptions

LoaderError
RuntimeError
SyntaxError

bool canConnectToMailServer(string $host, int $port)

Verify that we can connect to the mail server This tests basic connectivity before attempting to send mail

Parameters

string $host

The mail server host (with protocol prefix if needed)

int $port

The mail server port

Return Value

bool

True if connection was successful, false otherwise

bool isMailConfigurationValid()

Verify mail configuration is valid before attempting to send

Return Value

bool

True if mail configuration is valid, false otherwise