Verified Commit d36ffac1 authored by Helmo's avatar Helmo
Browse files

Rewrite email sending to use ispcmail, and translate

parent 8eaa875b
......@@ -36,5 +36,7 @@ $wb['otp_code_txt'] = 'Two Factor Authentication';
$wb['otp_code_desc_txt'] = 'Enter the code you got from your authenticator app or via email.';
$wb['otp_code_placeholder_txt'] = 'OTP code';
$wb['otp_code_email_sent_txt'] = 'An email was sent to';
$wb['otp_code_email_subject_txt'] = 'ISPConfig Login authentication';
$wb['otp_code_email_template_txt'] = 'Your One time login code is %s' . PHP_EOL . 'This code is valid for 10 minutes.' . PHP_EOL;
$wb['otp_code_resend_txt'] = 'Request new code';
?>
......@@ -142,16 +142,21 @@ if($_SESSION['otp']['type'] == 'email') {
$app->uses('functions');
$app->uses('getconf');
$system_config = $app->getconf->get_global_config();
$from = $system_config['mail']['admin_mail'];
$server_config_array = $app->getconf->get_global_config();
//* send email
$app->uses('getconf,ispcmail');
$mail_config = $server_config_array['mail'];
if($mail_config['smtp_enabled'] == 'y') {
$mail_config['use_smtp'] = true;
$app->ispcmail->setOptions($mail_config);
}
$email_to = $_SESSION['otp']['data'];
$subject = 'ISPConfig Login authentication';
$text = 'Your One time login code is ' . $new_otp_code . PHP_EOL
. 'This code is valid for 10 minutes' . PHP_EOL;
$app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']);
$app->ispcmail->setSubject($wb['otp_code_email_subject_txt']);
$app->ispcmail->setMailText(sprintf($wb['otp_code_email_template_txt'], $new_otp_code));
$send_result = $app->ispcmail->send($email_to);
$app->ispcmail->finish();
$app->functions->mail($email_to, $subject, $text, $from);
//* increase sent counter
if(!isset($_SESSION['otp']['sent'])) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment