#64047extbase mail wrapper for core mail; ActionMailer
Description
The current way to go when implementing mail delivery in an extbase extension seems to be http://wiki.typo3.org/How_to_use_the_Fluid_Standalone_view_to_render_template_based_emails. Peeking at out ActionController, extbase could provide the same architecture for looking up and rendering mails.
I’m just throwing my idea in here with a bit of pseudo-code, as this may explain things better than when writing it out. IMHO this would help extension developers to concentrate on building their extension and spare a lot of time writing / copy-pasting code to handle mail deliveries.
File structure
typo3conf/ext/<myext>
- Classes
- Mailer
- MyMailer.php
- Resources
- Private
- Templates
- MyMailer
MyMailer.php
class MyMailer extends \TYPO3\CMS\Extbase\Mailer\ActionMailer {
public function welcomeUserMail($user) {
/** @var \TYPO3\Core\Mail\Message */
$mail = $this->createMail();
/*
* ActionMailer base class sets layout and template automagically
* based on the current controller name and action name; This e.g. would be
*
* $templateRootPath/@MailerClassName/@MailerMethodName.html
*
* The only thing you actually do in here is set / assign data, similiar to the controller.
*/
$mail->setTo($user->getEmail());
$mail->setSubject('Successfully signed up!');
$mail->assign('user', $user); // Exposed to the fluid standalone view
return $mail->send();
}
}
MyController.php
public function confirmationAction() {
// ... creating $user ...
$mailer = makeInstance('MyMailer'); // or maybe instantiate it through DI's @inject?
$mailer->welcomeUserMail($user);
}Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.