File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -36,5 +36,7 @@ $wb['otp_code_txt'] = 'Two Factor Authentication';
3636$wb['otp_code_desc_txt'] = 'Enter the code you got from your authenticator app or via email.';
3737$wb['otp_code_placeholder_txt'] = 'OTP code';
3838$wb['otp_code_email_sent_txt'] = 'An email was sent to';
39+ $wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
40+ $wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
3941$wb['otp_code_resend_txt'] = 'Request new code';
4042?>
Original file line number Diff line number Diff line change @@ -142,16 +142,21 @@ function finish_2fa_success($msg = '') {
142142
143143 $ app ->uses ('functions ' );
144144 $ app ->uses ('getconf ' );
145- $ system_config = $ app ->getconf ->get_global_config ();
146- $ from = $ system_config ['mail ' ]['admin_mail ' ];
145+ $ server_config_array = $ app ->getconf ->get_global_config ();
147146
148- //* send email
147+ $ app ->uses ('getconf,ispcmail ' );
148+ $ mail_config = $ server_config_array ['mail ' ];
149+ if ($ mail_config ['smtp_enabled ' ] == 'y ' ) {
150+ $ mail_config ['use_smtp ' ] = true ;
151+ $ app ->ispcmail ->setOptions ($ mail_config );
152+ }
149153 $ email_to = $ _SESSION ['otp ' ]['data ' ];
150- $ subject = 'ISPConfig Login authentication ' ;
151- $ text = 'Your One time login code is ' . $ new_otp_code . PHP_EOL
152- . 'This code is valid for 10 minutes ' . PHP_EOL ;
154+ $ app ->ispcmail ->setSender ($ mail_config ['admin_mail ' ], $ mail_config ['admin_name ' ]);
155+ $ app ->ispcmail ->setSubject ($ wb ['otp_code_email_subject_txt ' ]);
156+ $ app ->ispcmail ->setMailText (sprintf ($ wb ['otp_code_email_template_txt ' ], $ new_otp_code ));
157+ $ send_result = $ app ->ispcmail ->send ($ email_to );
158+ $ app ->ispcmail ->finish ();
153159
154- $ app ->functions ->mail ($ email_to , $ subject , $ text , $ from );
155160
156161 //* increase sent counter
157162 if (!isset ($ _SESSION ['otp ' ]['sent ' ])) {
You can’t perform that action at this time.
0 commit comments