ok, das war ein guter Tipp. Mit typo3_conf funktioniert es!
Habe jetzt noch eine Frage (im Zusammenhang mit diesem Mailversand), da habe ich schon den ganzen gestrigen Abend damit verbracht und es nicht hinbekommen :-(
Habe hier ein Formular, welches ich gerne per Mail versenden möchte (das Formular ist völlig unabhängig von meinem Datenmodell (also nur ausfüllen und per Mail versenden):
Formular:
<form method="post" name="sendTemplateEmail" action="">
<label for="title">Vorname</label>
<input type="text" name="[recipient]" value="" />
<br>
<input class="submit" type="submit" value="Submit" />
</form>
Im Controller habe ich folgende Scripte:
/**
* action sendTemplateEmail
*
* @param \xxx\xxx\Domain\Model\Journeys $journeys
* @return void
*/
public function sendTemplateEmailAction($sender, $recipient, $subject, $templatename) {
//$this->view->assign('journeyss', $journeyss);
$this->sendTemplateEmail(array('glass@cgsolutions-online.de' => 'Recipient Name'), array('xy@web.de' => 'Sender Name'), 'Email Subject', 'TemplateName', array('someVariable' => 'Foo Bar'));
}
/**
* @param array $recipient recipient of the email in the format array('recipient@domain.tld' => 'Recipient Name')
* @param array $sender sender of the email in the format array('sender@domain.tld' => 'Sender Name')
* @param string $subject subject of the email
* @param string $templateName template name (UpperCamelCase)
* @param array $variables variables to be passed to the Fluid view
* @return boolean TRUE on success, otherwise false
*/
protected function sendTemplateEmail(array $recipient, array $sender, $subject, $templateName, array $variables = array()) {
/** @var \TYPO3\CMS\Fluid\View\StandaloneView $emailView; */
$emailView = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$templateRootPath = 'typo3conf/ext/xxx/Resources/Private/Templates';
//$templateRootPath = \TYPO3\CMS\Core\Utility\DebugUtility::debug(\TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($extbaseFrameworkConfiguration['view']['templateRootPath']));
$templatePathAndFilename = $templateRootPath . '/Email/' . $templateName . '.html';
$emailView->setTemplatePathAndFilename($templatePathAndFilename);
$emailView->assignMultiple($variables);
$emailBody = $emailView->render();
/** @var $message \TYPO3\CMS\Core\Mail\MailMessage */
$message = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
$message->setTo($recipient)
->setFrom($sender)
->setSubject($subject);
// Possible attachments here
//foreach ($attachments as $attachment) {
// $message->attach($attachment);
//}
// Plain text example
//$message->setBody($emailBody, 'text/plain');
// HTML Email
$message->setBody($emailBody, 'text/html');
$message->send();
return $message->isSent();
}
Nun möchte ich die Angaben/Parameter aus dem Formular, gerne an die Funktion
sendTemplateEmailAction($sender, $recipient, $subject, $templatename)
übergeben, welche ja wiederum die richtige Mailfunktion aufruft.
Habe mal mit dem $recipient anfangen möchten.
Was muss ich da genau im Feld im Formular angeben? Und wie kann ich das übergeben, da muss ich doch sicher noch ein GET irgendwo einfügen, oder?