Logging, mail and errors · Question 1 of 12

How is a MailMessage sent in TYPO3 v14?

1 answer is correct. Easy

Show answer

Answer

  • D Through a MailerInterface injected via dependency injection, with $this->mailer->send($mail)

Explanation

In TYPO3 v14 MailMessage is a pure data object: you set sender, recipient, subject and text, for example with ->from(), ->to(), ->subject() and ->text(). Sending is done by the service TYPO3\CMS\Core\Mail\MailerInterface, which you have injected via the constructor. The formerly common method $mail->send() was removed in v14, so old code fails with an error at this point. The mailer automatically uses the transport configured in $GLOBALS['TYPO3_CONF_VARS']['MAIL'].

Certifications & exams

Which exam comes next?

You can already practise for 19 exams, and 21 are up for a vote. See all certifications with their official information, cast your vote or suggest your exam.

See all certifications