Mailer class
Framework\Email\Mailer
Class Mailer.
Defined in libraries/email/src/Mailer.php
Properties #
- $config
- -
- $socket
- -
- $logs
- -
- $debugCollector
- -
- $lastResponse
- -
$config
protected array $config = array (
)
$socket
protected $socket = false
$logs
protected array $logs = array (
)
$debugCollector
protected \Framework\Email\Debug\EmailCollector $debugCollector
$lastResponse
protected ?string $lastResponse = NULL
Methods #
- __construct()
- Mailer constructor.
- __destruct()
- Disconnect from SMTP server.
- createMessage()
- Create a new Message instance.
- getConfig()
- Get a config value.
- getConfigs()
- Get all configs.
- getLastResponse()
- Get the last response.
- getLogs()
- Get an array of logs.
- resetLogs()
- Reset logs.
- send()
- Send an Email Message.
- setDebugCollector()
- Set the debug collector.
- addLog()
- -
- authenticate()
- -
- connect()
- -
- disconnect()
- -
- getResponse()
- Get Mail Server response.
- makeConfig()
- Make Base configurations.
- sendCommand()
- Send command to mail server.
- sendMessage()
- -
- setLastResponse()
- -
- makeResponseCode()
- -
__construct()
public function __construct(array|string $username, ?string $password = NULL, string $host = 'localhost', int $port = 587, ?string $hostname = NULL)
Mailer constructor.
Parameters
- array|string $username
- ?string $password
- string $host
- int $port
- ?string $hostname
__destruct()
public function __destruct()
Disconnect from SMTP server.
createMessage()
public function createMessage(): \Framework\Email\Message
Create a new Message instance.
Returns
\Framework\Email\Message
getConfig()
public function getConfig(string $key): mixed
Get a config value.
Parameters
- string $key - The config key
Returns
mixed
- The config value
getConfigs()
public function getConfigs(): array
Get all configs.
Returns
array
getLastResponse()
public function getLastResponse(): ?string
Get the last response.
Returns
?string
- The last response or null if there is none
getLogs()
public function getLogs(): array
Get an array of logs.
Contains commands and responses from the Mailer server.
Returns
array
resetLogs()
public function resetLogs(): static
Reset logs.
Returns
static
send()
public function send(\Framework\Email\Message $message): bool
Send an Email Message.
Parameters
- \Framework\Email\Message $message - The Message instance
Returns
bool
- True if successful, otherwise false
setDebugCollector()
public function setDebugCollector(\Framework\Email\Debug\EmailCollector $collector): static
Set the debug collector.
Parameters
- \Framework\Email\Debug\EmailCollector $collector - The debug collector
Returns
static
addLog()
protected function addLog(string $command, string $response): static
Parameters
- string $command
- string $response
Returns
static
authenticate()
protected function authenticate(): bool
Returns
bool
connect()
protected function connect(): bool
Returns
bool
disconnect()
protected function disconnect(): bool
Returns
bool
getResponse()
protected function getResponse(): string
Get Mail Server response.
Returns
string
makeConfig()
protected function makeConfig(array $config): array
Make Base configurations.
Parameters
- array $config
Returns
array
sendCommand()
protected function sendCommand(string $command): int
Send command to mail server.
Parameters
- string $command
Returns
int
- Response code
sendMessage()
protected function sendMessage(\Framework\Email\Message $message): int|false
Parameters
- \Framework\Email\Message $message
Returns
int|false
setLastResponse()
protected function setLastResponse(?string $lastResponse): static
Parameters
- ?string $lastResponse
Returns
static
makeResponseCode()
private function makeResponseCode(string $response): int
Parameters
- string $response
Returns
int