From d79e58346dbe9526686630eefa7c0db9ed2c9212 Mon Sep 17 00:00:00 2001 From: Brian Lycett Date: Wed, 1 Jun 2022 13:59:57 +0100 Subject: [PATCH] Issue 163 (#168) * Issue #163 - password reset warnings * Fix errors showing when accounts don't have an email. Fix errors when sending an email on password reset. Prevent PHPMailer trying to use TLS when it's disabled. Co-authored-by: Brian Lycett --- www/account_manager/index.php | 3 ++- www/account_manager/new_user.php | 4 ++-- www/account_manager/show_user.php | 8 ++++---- www/includes/mail_functions.inc.php | 1 + 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/www/account_manager/index.php b/www/account_manager/index.php index c6d5e28..ade7f0d 100644 --- a/www/account_manager/index.php +++ b/www/account_manager/index.php @@ -62,11 +62,12 @@ $people = ldap_get_user_list($ldap_connection); foreach ($people as $account_identifier => $attribs){ $group_membership = ldap_user_group_membership($ldap_connection,$account_identifier); + if (isset($people[$account_identifier]['mail'])) { $this_mail = $people[$account_identifier]['mail']; } else { $this_mail = ""; } print " \n $account_identifier\n"; print " " . $people[$account_identifier]['givenname'] . "\n"; print " " . $people[$account_identifier]['sn'] . "\n"; - print " " . $people[$account_identifier]['mail'] . "\n"; + print " $this_mail\n"; print " " . implode(", ", $group_membership) . "\n"; print " \n"; } diff --git a/www/account_manager/new_user.php b/www/account_manager/new_user.php index 7a8e4eb..c029eed 100644 --- a/www/account_manager/new_user.php +++ b/www/account_manager/new_user.php @@ -102,11 +102,11 @@ foreach ($attribute_map as $attribute => $attr_r) { if (isset($_GET['account_request'])) { $givenname[0]=filter_var($_GET['first_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); - $new_account_r['givenname'] = $givenname; + $new_account_r['givenname'] = $givenname[0]; unset($new_account_r['givenname']['count']); $sn[0]=filter_var($_GET['last_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS); - $new_account_r['sn'] = $sn; + $new_account_r['sn'] = $sn[0]; unset($new_account_r['sn']['count']); $mail[0]=filter_var($_GET['email'], FILTER_SANITIZE_EMAIL); diff --git a/www/account_manager/show_user.php b/www/account_manager/show_user.php index 8ea59d2..ba3a549 100644 --- a/www/account_manager/show_user.php +++ b/www/account_manager/show_user.php @@ -184,12 +184,12 @@ if ($ldap_search) { include_once "mail_functions.inc.php"; - $mail_body = parse_mail_text($new_account_mail_body, $password, $account_identifier, $givenname, $sn); - $mail_subject = parse_mail_text($new_account_mail_subject, $password, $account_identifier, $givenname, $sn); + $mail_body = parse_mail_text($new_account_mail_body, $password, $account_identifier, $givenname[0], $sn[0]); + $mail_subject = parse_mail_text($new_account_mail_subject, $password, $account_identifier, $givenname[0], $sn[0]); - $sent_email = send_email($mail,"$givenname $sn",$mail_subject,$mail_body); + $sent_email = send_email($mail[0],"${givenname[0]} ${sn[0]}",$mail_subject,$mail_body); if ($sent_email) { - $sent_email_message .= " An email sent to $mail."; + $sent_email_message .= " An email sent to ${mail[0]}."; } else { $sent_email_message .= " Unfortunately the email wasn't sent; check the logs for more information."; diff --git a/www/includes/mail_functions.inc.php b/www/includes/mail_functions.inc.php index 4fbda64..af2ba51 100644 --- a/www/includes/mail_functions.inc.php +++ b/www/includes/mail_functions.inc.php @@ -64,6 +64,7 @@ function send_email($recipient_email,$recipient_name,$subject,$body) { if ($SMTP['tls'] == TRUE) { $mail->SMTPSecure = 'tls'; } if ($SMTP['ssl'] == TRUE) { $mail->SMTPSecure = 'ssl'; } + $mail->SMTPAutoTLS = false; $mail->setFrom($EMAIL['from_address'], $EMAIL['from_name']); $mail->addAddress($recipient_email, $recipient_name); $mail->Subject = $subject;