Skip to content

Commit 7984a58

Browse files
authored
fix(backend): jmap config with smtp server (#1425)
* fix(backend): jmap config with smtp server
1 parent 70559b1 commit 7984a58

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

modules/core/handler_modules.php

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,21 @@ public function process() {
10701070
'srv_setup_stepper_smtp_server_id' => $smtpServerId
10711071
] = $form;
10721072

1073+
/*
1074+
* Connect to SMTP server if user wants to send emails
1075+
*/
1076+
if($isSender){
1077+
if (!$this->module_is_supported('smtp')) {
1078+
Hm_Msgs::add("SMTP module is not enabled",'danger');
1079+
return;
1080+
}
1081+
$this->smtp_server_id = connect_to_smtp_server($smtpAddress, $profileName, $smtpPort, $email, $password, $smtpTls, 'smtp', $smtpServerId);
1082+
if(!isset($this->smtp_server_id)){
1083+
Hm_Msgs::add("Could not save server", 'danger');
1084+
return;
1085+
}
1086+
}
1087+
10731088
/*
10741089
* When JMAP selected only configure JMAP
10751090
*/
@@ -1153,22 +1168,22 @@ public function process() {
11531168
};
11541169
}
11551170

1156-
if($isSender && $isReceiver && $createProfile && isset($this->imap_server_id) && isset($this->smtp_server_id) && ! ($smtpServerId || $imapServerId)) {
1157-
if (!$this->module_is_supported('profiles')) {
1158-
Hm_Msgs::add("Profiles module is not enabled", "danger");
1159-
return;
1160-
}
1161-
1162-
add_profile($profileName, $profileSignature, $profileReplyTo, $profileIsDefault, $email, $imapAddress, $email, $this->smtp_server_id, $this->imap_server_id, $this);
1163-
}
1164-
11651171
if ($this->module_is_supported('imap_folders')) {
11661172
$this->out('imap_server_id', $this->imap_server_id);
11671173
$this->out('imap_service_name', $provider);
11681174
}
11691175
$this->out('just_saved_credentials', true);
11701176
Hm_Msgs::add("Server saved");
11711177
}
1178+
1179+
if ($createProfile && $this->smtp_server_id && ($this->imap_server_id || $this->jmap_server_id)) {
1180+
if (!$this->module_is_supported('profiles')) {
1181+
Hm_Msgs::add("Profiles module is not enabled", "danger");
1182+
return;
1183+
}
1184+
1185+
add_profile($profileName, $profileSignature, $profileReplyTo, $profileIsDefault, $email, $imapAddress, $email, $this->smtp_server_id, $this->imap_server_id ?? $this->jmap_server_id, $this);
1186+
}
11721187
}
11731188
}
11741189
}

0 commit comments

Comments
 (0)