$ezlogger = new EZLogger("filename.log");
$ezlogger->sendMail($subject,$to,$sender);
public function sendMail(string $subject = "", Address|string $to = "", Address|string $sender = ""): bool
{
if (
$this->extensionConfiguration["activateLog"] == "1" &&
($to || $this->extensionConfiguration["mailReceiver"])
) {
$to = $to ?: $this->extensionConfiguration["mailReceiver"];
$mail = GeneralUtility::makeInstance(MailMessage::class);
$mail
->setSubject($subject ?? 'Report from EZ Logger')
->setTo($to)
->text("Hello, \n\nA new logfile has been generated. You can find it attached to this mail. \n\nHave a nice day!")
->attachFromPath($this->getLogFile(), 'logfile.log');
if ($sender || $this->extensionConfiguration["mailSender"]) {
$sender = $sender ?: $this->extensionConfiguration["mailSender"];
$mail
->from($sender)
->sender($sender);
}
return $mail->send();
}
return false;
}