fix issues from merging #958 - no longer provide smtp_password to smtp_mail(..) call, as it does it internally now

This commit is contained in:
David Goodwin committed 2026-01-01 13:40:17 +00:00
1 parent 5196a823ba
commit 7f1d78e2cd
4 files changed
+13 -15

No files matched your search

+8 -10
View File
@@ -1307,20 +1307,16 @@ function enable_socket_crypto($fh)
* Call: smtp_mail (string to, string from, string data) - DEPRECATED * Call: smtp_mail (string to, string from, string data) - DEPRECATED
* @param string $to * @param string $to
* @param string $from * @param string $from
* @param string $subject (if called with 4 parameters) or full mail body (if called with 3 parameters) * @param string $subject_or_data(if called with 4 parameters) or full mail body (if called with 3 parameters)
* @param string $password (optional) - Password * @param ?string $body (optional, but recommended) - mail body (if null, assume $subject_or_data is the entire mail body with headers etc)
* @param string $body (optional, but recommended) - mail body
* @return bool - true on success, otherwise false * @return bool - true on success, otherwise false
* I did something that is working with 465 and 587. The previous one doesnt work at all
* Sorry fot that. Had to do a litle tweak do work with broadcast-message.php
* Sorry for the bad english :D
*/ */
function smtp_mail($to, $from, $subject_or_data, $body = null) function smtp_mail(string $to, string $from, string $subject_or_data, ?string $body = null): bool
{ {
global $CONF; global $CONF;
$server = $CONF['smtp_server']; $server = $CONF['smtp_server'];
$port = (int)$CONF['smtp_port']; $port = (int)$CONF['smtp_port'];
$timeout = 30; $timeout = 30;
$helo = !empty($CONF['smtp_client']) $helo = !empty($CONF['smtp_client'])
@@ -1329,7 +1325,7 @@ function smtp_mail($to, $from, $subject_or_data, $body = null)
$username = $CONF['smtp_username'] ?? ''; $username = $CONF['smtp_username'] ?? '';
$password = $CONF['admin_smtp_password'] ?? ''; $password = $CONF['admin_smtp_password'] ?? '';
$type = $CONF['smtp_type'] ?? 'starttls'; $type = $CONF['smtp_type'] ?? 'starttls';
// Building of SMTP payload // Building of SMTP payload
if ($body === null) { if ($body === null) {
@@ -1403,6 +1399,7 @@ function smtp_mail($to, $from, $subject_or_data, $body = null)
return true; return true;
} }
//end //end
// auxiliary function // auxiliary function
function smtp_expect($socket, $code) function smtp_expect($socket, $code)
@@ -1421,6 +1418,7 @@ function smtp_expect($socket, $code)
} }
return true; return true;
} }
//end commit //end commit
/** /**
* smtp_get_admin_email * smtp_get_admin_email
+1 -1
View File
@@ -510,7 +510,7 @@ class MailboxHandler extends PFAHandler
$fSubject = Config::lang('pSendmail_subject_text'); $fSubject = Config::lang('pSendmail_subject_text');
$fBody = Config::read('welcome_text'); $fBody = Config::read('welcome_text');
if (!smtp_mail($fTo, $fFrom, $fSubject, smtp_get_admin_password(), $fBody)) { if (!smtp_mail($fTo, $fFrom, $fSubject, $fBody)) {
$this->errormsg[] = Config::lang_f('pSendmail_result_error', $this->id); $this->errormsg[] = Config::lang_f('pSendmail_result_error', $this->id);
return false; return false;
} }
+1 -1
View File
@@ -64,7 +64,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
} }
if ($error != 1) { if ($error != 1) {
if (!smtp_mail($fTo, $fFrom, $fSubject, smtp_get_admin_password(), $tBody)) { if (!smtp_mail($fTo, $fFrom, $fSubject, $tBody)) {
flash_error(Config::lang_f('pSendmail_result_error', $fTo)); flash_error(Config::lang_f('pSendmail_result_error', $fTo));
} else { } else {
flash_info(Config::lang_f('pSendmail_result_success', $fTo)); flash_info(Config::lang_f('pSendmail_result_success', $fTo));
+3 -3
View File
@@ -48,10 +48,10 @@ function sendCodebyEmail($to, $username, $code)
{ {
$url = getSiteUrl($_SERVER) . 'password-change.php?username=' . urlencode($username) . '&code=' . $code; $url = getSiteUrl($_SERVER) . 'password-change.php?username=' . urlencode($username) . '&code=' . $code;
return smtp_mail($to, return smtp_mail(
$to,
smtp_get_admin_email(false), smtp_get_admin_email(false),
Config::Lang('pPassword_welcome'), Config::Lang('pPassword_welcome'),
Config::read('admin_smtp_password'),
Config::lang_f('pPassword_recovery_email_body', $url)); Config::lang_f('pPassword_recovery_email_body', $url));
} }
@@ -108,7 +108,7 @@ if ($_SERVER['REQUEST_METHOD'] === "POST") {
// throttle password reset requests to prevent brute force attack // throttle password reset requests to prevent brute force attack
$elapsed_time = microtime(true) - $start_time; $elapsed_time = microtime(true) - $start_time;
if ($elapsed_time < 2 * pow(10, 6)) { if ($elapsed_time < 2 * pow(10, 6)) {
usleep((int) (2 * pow(10, 6) - $elapsed_time)); usleep((int)(2 * pow(10, 6) - $elapsed_time));
} }
flash_info(Config::Lang('pPassword_recovery_processed')); flash_info(Config::Lang('pPassword_recovery_processed'));