Breaking: #108097 - MailMessage->send() removed
See forge#108097
Description
Class
Mail is a data object that should not contain service
methods like
send. The following methods have been removed:
TYPO3\CMS\ Core\ Mail\ Mail Message->send () TYPO3\CMS\ Core\ Mail\ Mail Message->is Sent ()
Impact
Using the above 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
\TYPO3\ injected and should use
that service to
send the mail.
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);
}
}