Merge branch 'autoreply'
This commit is contained in:
@@ -56,13 +56,13 @@ class AjaxFormController extends ActionController
|
||||
public function processInquiryFormAction(Inquiry $inquiry)
|
||||
{
|
||||
$response['status'] = 'ok';
|
||||
$this->emailService->send(
|
||||
$this->settings['inquiryToEmail'],
|
||||
$this->settings['inquiryToName'],
|
||||
'Anfrage E&P Events',
|
||||
'Email/Inquiry',
|
||||
[ 'inquiry' => $inquiry ]
|
||||
);
|
||||
$this->emailService->send([
|
||||
'toEmail' => $this->settings['inquiryToEmail'],
|
||||
'toName' => $this->settings['inquiryToName'],
|
||||
'subject' => 'Anfrage E&P Events',
|
||||
'templateName' => 'Email/Inquiry',
|
||||
'variables' => [ 'inquiry' => $inquiry ]
|
||||
]);
|
||||
return json_encode($response);
|
||||
}
|
||||
|
||||
@@ -74,13 +74,13 @@ class AjaxFormController extends ActionController
|
||||
public function processConfiguratorFormAction(Inquiry $inquiry)
|
||||
{
|
||||
$response['status'] = 'ok';
|
||||
$this->emailService->send(
|
||||
$this->settings['inquiryToEmail'],
|
||||
$this->settings['inquiryToName'],
|
||||
'Anfrage E&P Events',
|
||||
'Email/Configurator',
|
||||
[ 'inquiry' => $inquiry ]
|
||||
);
|
||||
$this->emailService->send([
|
||||
'toEmail' => $this->settings['inquiryToEmail'],
|
||||
'toName' => $this->settings['inquiryToName'],
|
||||
'subject' => 'Anfrage E&P Events',
|
||||
'templateName' => 'Email/Configurator',
|
||||
'variables' => [ 'inquiry' => $inquiry ]
|
||||
]);
|
||||
return json_encode($response);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace EP\EpEvents\Service;
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use EP\EpEvents\Domain\Model\Inquiry;
|
||||
use TYPO3\CMS\Core\Mail\MailMessage;
|
||||
use TYPO3\CMS\Core\SingletonInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
@@ -59,17 +60,22 @@ class EmailService implements SingletonInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $toEmail
|
||||
* @param string $toName
|
||||
* @param string $subject
|
||||
* @param string $templateName
|
||||
* @param array $options
|
||||
* @param array $variables
|
||||
* @return bool
|
||||
*/
|
||||
public function send($toEmail, $toName, $subject, $templateName, array $variables = [])
|
||||
public function send(array $options)
|
||||
{
|
||||
$fromEmail = $this->settings['settings']['inquiryToEmail'];
|
||||
$fromName = $this->settings['settings']['inquiryToName'];
|
||||
$enableAutoreply = $this->settings['settings']['enableContactFormAutoreply'];
|
||||
$autoreplySubject = $this->settings['settings']['contactFormAutoreplySubject'];
|
||||
|
||||
$toEmail = $options['toEmail'];
|
||||
$toName = $options['toName'];
|
||||
$subject = $options['subject'];
|
||||
$templateName = $options['templateName'];
|
||||
$variables = $options['variables'];
|
||||
|
||||
/** @var MailMessage $message */
|
||||
$message = GeneralUtility::makeInstance(MailMessage::class);
|
||||
@@ -83,9 +89,32 @@ class EmailService implements SingletonInterface
|
||||
$view->assignMultiple($variables);
|
||||
$message->setBody($view->render(), 'text/html');
|
||||
|
||||
$message->send();
|
||||
$messageSent = $message->send();
|
||||
$autoreplySent = false;
|
||||
|
||||
return $message->isSent();
|
||||
if ($enableAutoreply) {
|
||||
/** @var Inquiry $inquiry */
|
||||
$inquiry = $variables['inquiry'];
|
||||
$toEmail = $inquiry->getEmail();
|
||||
$toName = $inquiry->getName();
|
||||
$templateName = 'Email/Autoreply';
|
||||
|
||||
/** @var MailMessage $message */
|
||||
$message = GeneralUtility::makeInstance(MailMessage::class);
|
||||
$message
|
||||
->setTo([$toEmail => $toName])
|
||||
->setFrom([$fromEmail => $fromName])
|
||||
->setSubject($autoreplySubject)
|
||||
;
|
||||
|
||||
$view = $this->getView($templateName);
|
||||
$view->assignMultiple($variables);
|
||||
$message->setBody($view->render(), 'text/html');
|
||||
|
||||
$autoreplySent = $message->send();
|
||||
}
|
||||
|
||||
return $messageSent && $autoreplySent;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,10 @@ plugin.tx_epevents {
|
||||
searchPageUid =
|
||||
# cat=plugin.tx_epevents//a; type=string; label=Inquiry recipient email
|
||||
inquiryToEmail =
|
||||
# cat=plugin.tx_epevents//a; type=boolean; label=Enable contact form autoreply
|
||||
enableContactFormAutoreply = 0
|
||||
# cat=plugin.tx_epevents//a; type=string; label=Contact form autoreply subject
|
||||
contactFormAutoreplySubject = Ihre Anfrage bei E&P Events
|
||||
# cat=plugin.tx_epevents//a; type=string; label=Inquiry recipient name
|
||||
inquiryToName =
|
||||
# cat=plugin.tx_epevents//a; type=string; label=Sitemap root page UID
|
||||
|
||||
@@ -46,6 +46,8 @@ plugin.tx_epevents {
|
||||
searchLogIgnoreIps = {$plugin.tx_epevents.settings.searchLogIgnoreIps}
|
||||
activityDefaultHeaderImage = {$plugin.tx_epevents.settings.activityDefaultHeaderImage}
|
||||
activityDefaultKeywordsImage = {$plugin.tx_epevents.settings.activityDefaultKeywordsImage}
|
||||
enableContactFormAutoreply = {$plugin.tx_epevents.settings.enableContactFormAutoreply}
|
||||
contactFormAutoreplySubject = {$plugin.tx_epevents.settings.contactFormAutoreplySubject}
|
||||
configurator {
|
||||
options {
|
||||
travelType {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" lang="en"
|
||||
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
|
||||
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers">
|
||||
|
||||
<f:layout name="Email"/>
|
||||
|
||||
<f:section name="Main">
|
||||
<p>Sehr geehrte Damen und Herren,</p>
|
||||
<p>auf Grund einer internen Schulung ist unser Büro bis Dienstag, 24.04.2018 nicht besetzt.</p>
|
||||
<p>In dringenden Fällen schreiben Sie eine Mail an [email protected], die E-Mails werden nur in
|
||||
unregelmäßigen Abständen gelesen.</p>
|
||||
<p>Vielen Dank.</p>
|
||||
</f:section>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user