Skip to content

Commit

Permalink
Add abiility to set replyTo in mail to form owner (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrode authored Jul 19, 2024
1 parent 935a05c commit 1a5f6c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Classes/Controller/EmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ public function createAction(\Slub\SlubForms\Domain\Model\Email $newEmail, array
$this->sendTemplateEmail(
array($newEmail->getSenderEmail() => $newEmail->getSenderName()),
array($this->settings['senderEmailAddress'] => LocalizationUtility::translate('slub-forms.senderEmailName', 'slub_forms') . ' - noreply'),
array()
LocalizationUtility::translate('slub-forms.senderSubject', 'slub_forms') . ' ' . $form->getTitle(),
'ConfirmEmail',
array( 'email' => $newEmail,
Expand All @@ -350,10 +351,15 @@ public function createAction(\Slub\SlubForms\Domain\Model\Email $newEmail, array
if($this->settings['overwriteFromEmailAdressToOwner'] && strlen($this->settings['overwriteFromEmailAdressToOwner']) > 0) {
$senderEmail = $this->settings['overwriteFromEmailAdressToOwner'];
}
$replyto = array();
if($this->settings['setReplyTo'] && intval($this->settings['setReplyTo']) === 1) {
$replyto = array($newEmail->getSenderEmail() => '');
}

$this->sendTemplateEmail(
array($form->getRecipient() => ''),
array($senderEmail => $newEmail->getSenderName()),
$replyto,
LocalizationUtility::translate('tx_slubforms_domain_model_email.form', 'slub_forms') . ': ' . $form->getTitle() . ': '. $newEmail->getSenderName(). ', '. $newEmail->getSenderEmail() ,
'FormEmail',
array( 'email' => $newEmail,
Expand Down Expand Up @@ -440,12 +446,13 @@ public function getSessionData($key) {
*
* @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 array $replyto replyto 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()) {
protected function sendTemplateEmail(array $recipient, array $sender, array $replyto, $subject, $templateName, array $variables = array()) {

/** @var \TYPO3\CMS\Fluid\View\StandaloneView $emailViewHTML */
$emailViewHTML = $this->objectManager->get(\TYPO3\CMS\Fluid\View\StandaloneView::class);
Expand All @@ -465,6 +472,7 @@ protected function sendTemplateEmail(array $recipient, array $sender, $subject,

$message->setTo($recipient)
->setFrom($sender)
->setReplyTo($replyto)
->setCharset('utf-8')
->setSubject($subject);

Expand Down
2 changes: 2 additions & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ plugin.tx_slubforms {

overwriteFromEmailAdressToOwner = noreply@slub-dresden.de

setReplyTo = 1

// allow sending anonymous mails
#anonymEmails {
# allow = 1
Expand Down

0 comments on commit 1a5f6c6

Please sign in to comment.