Skip to content

Commit fff0d43

Browse files
Enhance email settings functionality by adding sender address support
1 parent 55bbb47 commit fff0d43

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

api/app/Http/Requests/Workspace/EmailSettingsRequest.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,33 @@ public function __construct(Request $request, Workspace $workspace)
2222
*/
2323
public function rules()
2424
{
25-
$allFieldsPresent = $this->filled(['host', 'port', 'username', 'password']);
25+
$allFieldsPresent = $this->filled(['host', 'port', 'username', 'password', 'sender_address']);
2626

2727
return [
2828
'host' => [
2929
$allFieldsPresent ? 'required' : 'nullable',
30-
'required_with:port,username,password',
30+
'required_with:port,username,password,sender_address',
3131
'string',
3232
],
3333
'port' => [
3434
$allFieldsPresent ? 'required' : 'nullable',
35-
'required_with:host,username,password',
35+
'required_with:host,username,password,sender_address',
3636
'integer',
3737
],
3838
'username' => [
3939
$allFieldsPresent ? 'required' : 'nullable',
40-
'required_with:host,port,password',
40+
'required_with:host,port,password,sender_address',
4141
'string',
4242
],
4343
'password' => [
4444
$allFieldsPresent ? 'required' : 'nullable',
45-
'required_with:host,port,username',
45+
'required_with:host,port,username,sender_address',
4646
'string',
4747
],
48+
'sender_address' => [
49+
'nullable',
50+
'email',
51+
],
4852
];
4953
}
5054

api/app/Notifications/Forms/FormEmailNotification.php

+11
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,17 @@ private function formatSubmissionData($createLinks = true): array
9898

9999
private function getFromEmail(): string
100100
{
101+
$workspace = $this->event->form->workspace;
102+
$emailSettings = $workspace->settings['email_settings'] ?? [];
103+
104+
if (
105+
$workspace->is_pro
106+
&& $emailSettings
107+
&& !empty($emailSettings['sender_address'])
108+
) {
109+
return $emailSettings['sender_address'];
110+
}
111+
101112
if (
102113
config('app.self_hosted')
103114
&& isset($this->integrationData->sender_email)

client/components/pages/settings/WorkSpaceEmailSettings.vue

+11-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@
7171
label="Password"
7272
placeholder="Password"
7373
/>
74+
<TextInput
75+
:form="emailSettingsForm"
76+
name="sender_address"
77+
:disabled="!workspace.is_pro"
78+
label="Sender address"
79+
placeholder="sender@example.com"
80+
/>
7481

7582
<div class="flex justify-between gap-2">
7683
<UButton
@@ -115,7 +122,8 @@ const emailSettingsForm = useForm({
115122
host: '',
116123
port: '',
117124
username: '',
118-
password: ''
125+
password: '',
126+
sender_address: ''
119127
})
120128
const emailSettingsLoading = ref(false)
121129
const showEmailSettingsModal = ref(false)
@@ -148,6 +156,7 @@ const saveChanges = () => {
148156
port: emailSettingsForm?.port,
149157
username: emailSettingsForm?.username,
150158
password: emailSettingsForm?.password,
159+
sender_address: emailSettingsForm?.sender_address,
151160
},
152161
})
153162
.then((data) => {
@@ -171,5 +180,6 @@ const initEmailSettings = () => {
171180
emailSettingsForm.port = emailSettings?.port
172181
emailSettingsForm.username = emailSettings?.username
173182
emailSettingsForm.password = emailSettings?.password
183+
emailSettingsForm.sender_address = emailSettings?.sender_address
174184
}
175185
</script>

0 commit comments

Comments
 (0)