Customised email reply to (#186)
Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
parent
c66c09e17b
commit
a06a43c01c
|
@ -9,6 +9,7 @@ use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class SubmissionConfirmationMail extends OpenFormMail implements ShouldQueue
|
class SubmissionConfirmationMail extends OpenFormMail implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -36,7 +37,7 @@ class SubmissionConfirmationMail extends OpenFormMail implements ShouldQueue
|
||||||
->outputStringsOnly();
|
->outputStringsOnly();
|
||||||
|
|
||||||
return $this
|
return $this
|
||||||
->replyTo($form->creator->email)
|
->replyTo($this->getReplyToEmail($form->creator->email))
|
||||||
->from($this->getFromEmail(), $form->notification_sender)
|
->from($this->getFromEmail(), $form->notification_sender)
|
||||||
->subject($form->notification_subject)
|
->subject($form->notification_subject)
|
||||||
->markdown('mail.form.confirmation-submission-notification',[
|
->markdown('mail.form.confirmation-submission-notification',[
|
||||||
|
@ -52,4 +53,10 @@ class SubmissionConfirmationMail extends OpenFormMail implements ShouldQueue
|
||||||
$originalFromAddress = Str::of(config('mail.from.address'))->explode('@');
|
$originalFromAddress = Str::of(config('mail.from.address'))->explode('@');
|
||||||
return $originalFromAddress->first(). '+' . time() . '@' . $originalFromAddress->last();
|
return $originalFromAddress->first(). '+' . time() . '@' . $originalFromAddress->last();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getReplyToEmail($default)
|
||||||
|
{
|
||||||
|
$replyTo = Arr::get((array)$this->event->form->notification_settings, 'confirmation_reply_to', null);
|
||||||
|
return $replyTo ?? $default;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class FormSubmissionNotification extends Notification implements ShouldQueue
|
class FormSubmissionNotification extends Notification implements ShouldQueue
|
||||||
{
|
{
|
||||||
|
@ -68,6 +69,10 @@ class FormSubmissionNotification extends Notification implements ShouldQueue
|
||||||
|
|
||||||
private function getReplyToEmail($default)
|
private function getReplyToEmail($default)
|
||||||
{
|
{
|
||||||
|
$replyTo = Arr::get((array)$this->event->form->notification_settings, 'notification_reply_to', null);
|
||||||
|
if ($replyTo && $this->validateEmail($replyTo)) {
|
||||||
|
return $replyTo;
|
||||||
|
}
|
||||||
return $this->getRespondentEmail() ?? $default;
|
return $this->getRespondentEmail() ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<form-notifications-option />
|
<form-notifications-option />
|
||||||
|
<form-notifications-submission-confirmation />
|
||||||
<form-notifications-slack />
|
<form-notifications-slack />
|
||||||
<form-notifications-discord />
|
<form-notifications-discord />
|
||||||
<form-notifications-submission-confirmation />
|
|
||||||
|
|
||||||
</collapse>
|
</collapse>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -33,11 +33,18 @@
|
||||||
</h2>
|
</h2>
|
||||||
<toggle-switch-input name="notifies" :form="form" class="mt-4"
|
<toggle-switch-input name="notifies" :form="form" class="mt-4"
|
||||||
label="Receive email notifications on submission"
|
label="Receive email notifications on submission"
|
||||||
:help="notifiesHelp"
|
|
||||||
/>
|
|
||||||
<text-area-input v-if="form.notifies" name="notification_emails" :form="form" class="mt-4"
|
|
||||||
label="Notification Emails" help="Add one email per line"
|
|
||||||
/>
|
/>
|
||||||
|
<template v-if="form.notifies">
|
||||||
|
<text-input name="notification_reply_to"
|
||||||
|
v-model="form.notification_settings.notification_reply_to" class="mt-4"
|
||||||
|
label="Notification Reply To"
|
||||||
|
:help="notifiesHelp"
|
||||||
|
/>
|
||||||
|
<text-area-input name="notification_emails" :form="form" class="mt-4"
|
||||||
|
label="Notification Emails" help="Add one email per line"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</modal>
|
</modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -73,9 +80,9 @@ export default {
|
||||||
},
|
},
|
||||||
notifiesHelp () {
|
notifiesHelp () {
|
||||||
if (this.replayToEmailField) {
|
if (this.replayToEmailField) {
|
||||||
return 'Reply-to for this notification will be the email filled in the field "' + this.replayToEmailField.name + '".'
|
return 'If empty, Reply-to for this notification will be the email filled in the field "' + this.replayToEmailField.name + '".'
|
||||||
}
|
}
|
||||||
return 'Reply-to for this notification will be your own email. Add a single email field to your form, and it will automatically become the reply to value.'
|
return 'If empty, Reply-to for this notification will be your own email. Add a single email field to your form, and it will automatically become the reply to value.'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -31,22 +31,32 @@
|
||||||
:form="form" class="mt-4"
|
:form="form" class="mt-4"
|
||||||
label="Send submission confirmation" :help="emailSubmissionConfirmationHelp"
|
label="Send submission confirmation" :help="emailSubmissionConfirmationHelp"
|
||||||
/>
|
/>
|
||||||
<text-input v-if="form.send_submission_confirmation" name="notification_sender"
|
<template v-if="form.send_submission_confirmation">
|
||||||
:form="form" class="mt-4"
|
<text-input name="confirmation_reply_to"
|
||||||
label="Confirmation Email Sender Name" help="Emails will be sent from our email address but you can customize the name of the Sender"
|
v-model="form.notification_settings.confirmation_reply_to" class="mt-4"
|
||||||
/>
|
label="Confirmation Reply To" help="help"
|
||||||
<text-input v-if="form.send_submission_confirmation" name="notification_subject"
|
>
|
||||||
:form="form" class="mt-4"
|
<template #help>
|
||||||
label="Confirmation email subject" help="Subject of the confirmation email that will be sent"
|
If empty, Reply-to will be your own email.
|
||||||
/>
|
</template>
|
||||||
<rich-text-area-input v-if="form.send_submission_confirmation" name="notification_body"
|
</text-input>
|
||||||
:form="form" class="mt-4"
|
<text-input name="notification_sender"
|
||||||
label="Confirmation email content" help="Content of the confirmation email that will be sent"
|
:form="form" class="mt-4"
|
||||||
/>
|
label="Confirmation Email Sender Name" help="Emails will be sent from our email address but you can customize the name of the Sender"
|
||||||
<toggle-switch-input v-if="form.send_submission_confirmation" name="notifications_include_submission"
|
/>
|
||||||
:form="form" class="mt-4"
|
<text-input name="notification_subject"
|
||||||
label="Include submission data" help="If enabled the confirmation email will contain form submission answers"
|
:form="form" class="mt-4"
|
||||||
/>
|
label="Confirmation email subject" help="Subject of the confirmation email that will be sent"
|
||||||
|
/>
|
||||||
|
<rich-text-area-input name="notification_body"
|
||||||
|
:form="form" class="mt-4"
|
||||||
|
label="Confirmation email content" help="Content of the confirmation email that will be sent"
|
||||||
|
/>
|
||||||
|
<toggle-switch-input name="notifications_include_submission"
|
||||||
|
:form="form" class="mt-4"
|
||||||
|
label="Include submission data" help="If enabled the confirmation email will contain form submission answers"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</modal>
|
</modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
@if($form->editable_submissions)
|
@if($form->editable_submissions)
|
||||||
@component('mail::button', ['url' => $form->share_url.'?submission_id='.$submission_id])
|
@component('mail::button', ['url' => $form->share_url.'?submission_id='.$submission_id])
|
||||||
{{$form.editable_submissions_button_text}}
|
{{($form->editable_submissions_button_text ?? 'Edit submission')}}
|
||||||
@endcomponent
|
@endcomponent
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue