Customised email reply to (#186)
Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
@@ -9,6 +9,7 @@ use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class SubmissionConfirmationMail extends OpenFormMail implements ShouldQueue
|
||||
{
|
||||
@@ -36,7 +37,7 @@ class SubmissionConfirmationMail extends OpenFormMail implements ShouldQueue
|
||||
->outputStringsOnly();
|
||||
|
||||
return $this
|
||||
->replyTo($form->creator->email)
|
||||
->replyTo($this->getReplyToEmail($form->creator->email))
|
||||
->from($this->getFromEmail(), $form->notification_sender)
|
||||
->subject($form->notification_subject)
|
||||
->markdown('mail.form.confirmation-submission-notification',[
|
||||
@@ -52,4 +53,10 @@ class SubmissionConfirmationMail extends OpenFormMail implements ShouldQueue
|
||||
$originalFromAddress = Str::of(config('mail.from.address'))->explode('@');
|
||||
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\Notification;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class FormSubmissionNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
@@ -68,6 +69,10 @@ class FormSubmissionNotification extends Notification implements ShouldQueue
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user