Skip to content

Beautiful Open-Source Form Builder

Enhance email settings functionality by adding sender address support (#668)

Chirag Chhatrala4fae4e6328e9
diff --git a/api/app/Http/Requests/Workspace/EmailSettingsRequest.php b/api/app/Http/Requests/Workspace/EmailSettingsRequest.php
index 04030bc37..ca0c2e610 100644
--- a/api/app/Http/Requests/Workspace/EmailSettingsRequest.php
+++ b/api/app/Http/Requests/Workspace/EmailSettingsRequest.php
@@ -22,29 +22,33 @@ class EmailSettingsRequest extends FormRequest
*/
public function rules()
{
- $allFieldsPresent = $this->filled(['host', 'port', 'username', 'password']);
+ $allFieldsPresent = $this->filled(['host', 'port', 'username', 'password', 'sender_address']);
return [
'host' => [
$allFieldsPresent ? 'required' : 'nullable',
- 'required_with:port,username,password',
+ 'required_with:port,username,password,sender_address',
'string',
],
'port' => [
$allFieldsPresent ? 'required' : 'nullable',
- 'required_with:host,username,password',
+ 'required_with:host,username,password,sender_address',
'integer',
],
'username' => [
$allFieldsPresent ? 'required' : 'nullable',
- 'required_with:host,port,password',
+ 'required_with:host,port,password,sender_address',
'string',
],
'password' => [
$allFieldsPresent ? 'required' : 'nullable',
- 'required_with:host,port,username',
+ 'required_with:host,port,username,sender_address',
'string',
],
+ 'sender_address' => [
+ 'nullable',
+ 'email',
+ ],
];
}
diff --git a/api/app/Notifications/Forms/FormEmailNotification.php b/api/app/Notifications/Forms/FormEmailNotification.php
index 8d37082b5..ed0ad3e54 100644
--- a/api/app/Notifications/Forms/FormEmailNotification.php
+++ b/api/app/Notifications/Forms/FormEmailNotification.php
@@ -98,6 +98,17 @@ class FormEmailNotification extends Notification
private function getFromEmail(): string
{
+ $workspace = $this->event->form->workspace;
+ $emailSettings = $workspace->settings['email_settings'] ?? [];
+
+ if (
+ $workspace->is_pro
+ && $emailSettings
+ && !empty($emailSettings['sender_address'])
+ ) {
+ return $emailSettings['sender_address'];
+ }
+
if (
config('app.self_hosted')
&& isset($this->integrationData->sender_email)
diff --git a/client/components/pages/settings/WorkSpaceEmailSettings.vue b/client/components/pages/settings/WorkSpaceEmailSettings.vue
index 88dbd15c5..08bccb376 100644
--- a/client/components/pages/settings/WorkSpaceEmailSettings.vue
+++ b/client/components/pages/settings/WorkSpaceEmailSettings.vue
@@ -71,6 +71,13 @@
label="Password"
placeholder="Password"
/>
+ <TextInput
+ :form="emailSettingsForm"
+ name="sender_address"
+ :disabled="!workspace.is_pro"
+ label="Sender address"
+ placeholder="[email protected]"
+ />
<div class="flex justify-between gap-2">
<UButton
@@ -115,7 +122,8 @@ const emailSettingsForm = useForm({
host: '',
port: '',
username: '',
- password: ''
+ password: '',
+ sender_address: ''
})
const emailSettingsLoading = ref(false)
const showEmailSettingsModal = ref(false)
@@ -148,6 +156,7 @@ const saveChanges = () => {
port: emailSettingsForm?.port,
username: emailSettingsForm?.username,
password: emailSettingsForm?.password,
+ sender_address: emailSettingsForm?.sender_address,
},
})
.then((data) => {
@@ -171,5 +180,6 @@ const initEmailSettings = () => {
emailSettingsForm.port = emailSettings?.port
emailSettingsForm.username = emailSettings?.username
emailSettingsForm.password = emailSettings?.password
+ emailSettingsForm.sender_address = emailSettings?.sender_address
}
</script>