This commit is contained in:
Julien Nahum 2025-01-27 18:24:33 +01:00
commit c49af07aa1
3 changed files with 31 additions and 6 deletions

View File

@ -22,29 +22,33 @@ class EmailSettingsRequest extends FormRequest
*/ */
public function rules() public function rules()
{ {
$allFieldsPresent = $this->filled(['host', 'port', 'username', 'password']); $allFieldsPresent = $this->filled(['host', 'port', 'username', 'password', 'sender_address']);
return [ return [
'host' => [ 'host' => [
$allFieldsPresent ? 'required' : 'nullable', $allFieldsPresent ? 'required' : 'nullable',
'required_with:port,username,password', 'required_with:port,username,password,sender_address',
'string', 'string',
], ],
'port' => [ 'port' => [
$allFieldsPresent ? 'required' : 'nullable', $allFieldsPresent ? 'required' : 'nullable',
'required_with:host,username,password', 'required_with:host,username,password,sender_address',
'integer', 'integer',
], ],
'username' => [ 'username' => [
$allFieldsPresent ? 'required' : 'nullable', $allFieldsPresent ? 'required' : 'nullable',
'required_with:host,port,password', 'required_with:host,port,password,sender_address',
'string', 'string',
], ],
'password' => [ 'password' => [
$allFieldsPresent ? 'required' : 'nullable', $allFieldsPresent ? 'required' : 'nullable',
'required_with:host,port,username', 'required_with:host,port,username,sender_address',
'string', 'string',
], ],
'sender_address' => [
'nullable',
'email',
],
]; ];
} }

View File

@ -98,6 +98,17 @@ class FormEmailNotification extends Notification
private function getFromEmail(): string 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 ( if (
config('app.self_hosted') config('app.self_hosted')
&& isset($this->integrationData->sender_email) && isset($this->integrationData->sender_email)

View File

@ -71,6 +71,13 @@
label="Password" label="Password"
placeholder="Password" placeholder="Password"
/> />
<TextInput
:form="emailSettingsForm"
name="sender_address"
:disabled="!workspace.is_pro"
label="Sender address"
placeholder="sender@example.com"
/>
<div class="flex justify-between gap-2"> <div class="flex justify-between gap-2">
<UButton <UButton
@ -115,7 +122,8 @@ const emailSettingsForm = useForm({
host: '', host: '',
port: '', port: '',
username: '', username: '',
password: '' password: '',
sender_address: ''
}) })
const emailSettingsLoading = ref(false) const emailSettingsLoading = ref(false)
const showEmailSettingsModal = ref(false) const showEmailSettingsModal = ref(false)
@ -148,6 +156,7 @@ const saveChanges = () => {
port: emailSettingsForm?.port, port: emailSettingsForm?.port,
username: emailSettingsForm?.username, username: emailSettingsForm?.username,
password: emailSettingsForm?.password, password: emailSettingsForm?.password,
sender_address: emailSettingsForm?.sender_address,
}, },
}) })
.then((data) => { .then((data) => {
@ -171,5 +180,6 @@ const initEmailSettings = () => {
emailSettingsForm.port = emailSettings?.port emailSettingsForm.port = emailSettings?.port
emailSettingsForm.username = emailSettings?.username emailSettingsForm.username = emailSettings?.username
emailSettingsForm.password = emailSettings?.password emailSettingsForm.password = emailSettings?.password
emailSettingsForm.sender_address = emailSettings?.sender_address
} }
</script> </script>