Typo3 10 send mails
Man kann das jetzt über Fluid (> 10.3) machen oder MailMessage
Fluid:
use Symfony\Component\Mime\Address;
use TYPO3\CMS\Core\Mail\FluidEmail;
use TYPO3\CMS\Core\Mail\Mailer;
$email = GeneralUtility::makeInstance(FluidEmail::class);
$email
->to('contact@acme.com')
->from(new Address('jeremy@acme.com', 'Jeremy'))
->subject('TYPO3 loves you - here is why')
->format('both') // send HTML and plaintext mail
->setTemplate('TipsAndTricks')
->assign('mySecretIngredient', 'Tomato and TypoScript');
GeneralUtility::makeInstance(Mailer::class)->send($email);
MailMessage
/ Create the message
$mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
// Prepare and send the message
$mail
// Defining the "From" email address and name as an object
// (email clients will display the name)
->from(new \Symfony\Component\Mime\Address('john@doe.com', 'John Doe'))
// Set the "To" addresses
->to(
new \Symfony\Component\Mime\Address('receiver@example.org', 'Max Mustermann'),
new \Symfony\Component\Mime\Address('other@domain.org')
)
// Give the message a subject
->subject('Your subject')
// Give it the text message
->text('Here is the message itself')
// And optionally a HTML message
->html('<p>Here is the message itself</p>')
// Optionally add any attachments
->attachFromPath('/path/to/my-document.pdf')
// And finally send it
->send()
;
Mehr Infos: