Breaking: #108097 - MailMessage->send() removed
See forge#108097
Description
Class
\TYPO3\ is a data object that
should not contain service methods like
send. The following methods
have been removed from this class:
send() isSent ()
Impact
Using the removed methods on instances of this class will raise fatal PHP errors.
Affected installations
Instances that create
Mail objects
and call
send or
is are affected. The extension scanner
is not configured to find affected code since the method names are too generic.
Migration
The service (usually a controller class) that sends emails should be
reconfigured to get an instance of
Mailer
injected and should use that service to call
send.
Example before:
use TYPO3\CMS\Core\Mail\MailMessage;
final readonly class MyController
{
public function sendMail()
{
$email = new MailMessage();
$email->subject('Some subject');
$email->send();
}
}
Example after:
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Mail\MailerInterface;
final readonly class MyController
{
public function __construct(
private MailerInterface $mailer
) {}
public function sendMail()
{
$email = new MailMessage();
$email->subject('Some subject');
$this->mailer->send($email);
}
}