Skip to content

Commit d36ffac

Browse files
committed
Rewrite email sending to use ispcmail, and translate
1 parent 8eaa875 commit d36ffac

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

interface/web/login/lib/lang/en.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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
?>

interface/web/login/otp.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff 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'])) {

0 commit comments

Comments
 (0)