TYPO3 10.4.20:使用不同的模板文件发送电子邮件不起作用

TYPO3 10.4.20: Send email with different template files not working

我的 TYPO3 自定义扩展名上有 2 个表格。一共有3个模板文件。

请看我的代码,你能帮我指出它有什么问题吗?

现在,当我点击提交按钮时出现以下错误:

// Set user email template
if(!empty($arguments['requestform'])) {
    $setTemplateAdmin = $this->setTemplateAdmin();
    $setTemplateUser = $this->setTemplateUser();
}else{
    $setTemplateFreeTrialAdmin = $this->setTemplateFreeTrialAdmin();
}
exit;




//subject request Admin Template
public function setTemplateAdmin(){
    $this->view->setTemplatePathAndFilename(ExtensionManagementUtility::extPath('my_extension').
            'Resources/Private/Templates/my_extension/AdminEmail.html');
    $this->view->assignMultiple([
        'mailOutput' => $userData,
        'settings' => $this->settings,
        'baseurl' => $GLOBALS['TSFE']->config['config']['baseURL']
    ]);
    $mailBody = $this->view->render();
    $mailSent = $this->sendEmail($mailBody, $userData['email'], $this->settings, $userData['requestform']);
}

//subject request User template
public function setTemplateUser(){
    $this->view->setTemplatePathAndFilename(ExtensionManagementUtility::extPath('my_extensionn').
            'Resources/Private/Templates/my_extension/RequestSubUserEmail.html');
    $this->view->assignMultiple([
        'mailOutput' => $userData,
        'settings' => $this->settings,
        'baseurl' => $GLOBALS['TSFE']->config['config']['baseURL']
    ]);
    $mailBodyUser = $this->view->render();
    $mailSent = $this->sendEmailUser($mailBodyUser, $userData['email'], $this->settings, $userData['requestform']);
}

//Trial request user mail
public function setTemplateFreeTrialAdmin(){
    $this->view->setTemplatePathAndFilename(ExtensionManagementUtility::extPath('my_extension').
    'Resources/Private/Templates/my_extension/UserEmail.html');
    $this->view->assignMultiple([
        'mailOutput' => $userData,
        'settings' => $this->settings,
        'baseurl' => $GLOBALS['TSFE']->config['config']['baseURL']
    ]);
    $mailBody = $this->view->render();
    $mailSent = $this->sendEmail($mailBody, $userData['email'], $this->settings, $userData['requestform']);
}

// Send Email
public function sendEmail($mailBody, $userEmail, $settings, $requestform)
{
    $mail = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
    if(!empty($requestform)) {
        $mail
            ->from(new \Symfony\Component\Mime\Address($settings['adminfromemail'], $settings['adminfromname']))
            ->to(new \Symfony\Component\Mime\Address($settings['admintoemail']))
            ->subject($settings['subreqmailsubject'])
            ->html($mailBody)
            ->send();
    } else {
        $mail
            ->from(new \Symfony\Component\Mime\Address($settings['adminfromemail'], $settings['adminfromname']))
            ->to(new \Symfony\Component\Mime\Address($userEmail))
            ->subject($settings['adminmailsubject'])
            ->html($mailBody)
            ->send();
    }
}

// Send User Email for Subject Request Form
public function sendEmailUser($mailBodyUser, $userEmail, $settings, $requestform)
{
    $mail = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
    $mail
        ->from(new \Symfony\Component\Mime\Address($settings['adminfromemail'], $settings['adminfromname']))
        ->to(new \Symfony\Component\Mime\Address($userEmail))
        ->subject($settings['subrequsermailsubject'])
        ->html($mailBodyUser)
        ->send();
}

$userEmail 是值电子邮件字段。我觉得它的价值没有得到。

表单未提交,显示 500 错误。

通过$userData函数调用

if(!empty($arguments['requestform'])) {
            $setTemplateAdmin = $this->setTemplateAdmin($userData);
            $setTemplateUser = $this->setTemplateUser($userData);
        }else{
            $setTemplateFreeTrialAdmin = $this->setTemplateFreeTrialAdmin($userData);
        }
        exit;

并且还在函数定义处声明变量

    public function setTemplateAdmin($userData){
//code here
}