mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2026-11-20 23:43:26 +03:00
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:
4 files changed
+13
-15
No files matched your search
+8
-10
@@ -1307,20 +1307,16 @@ function enable_socket_crypto($fh)
|
||||
* Call: smtp_mail (string to, string from, string data) - DEPRECATED
|
||||
* @param string $to
|
||||
* @param string $from
|
||||
* @param string $subject (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
|
||||
* @param string $subject_or_data(if called with 4 parameters) or full mail body (if called with 3 parameters)
|
||||
* @param ?string $body (optional, but recommended) - mail body (if null, assume $subject_or_data is the entire mail body with headers etc)
|
||||
* @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;
|
||||
|
||||
$server = $CONF['smtp_server'];
|
||||
$port = (int)$CONF['smtp_port'];
|
||||
$server = $CONF['smtp_server'];
|
||||
$port = (int)$CONF['smtp_port'];
|
||||
$timeout = 30;
|
||||
|
||||
$helo = !empty($CONF['smtp_client'])
|
||||
@@ -1329,7 +1325,7 @@ function smtp_mail($to, $from, $subject_or_data, $body = null)
|
||||
|
||||
$username = $CONF['smtp_username'] ?? '';
|
||||
$password = $CONF['admin_smtp_password'] ?? '';
|
||||
$type = $CONF['smtp_type'] ?? 'starttls';
|
||||
$type = $CONF['smtp_type'] ?? 'starttls';
|
||||
|
||||
// Building of SMTP payload
|
||||
if ($body === null) {
|
||||
@@ -1403,6 +1399,7 @@ function smtp_mail($to, $from, $subject_or_data, $body = null)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//end
|
||||
// auxiliary function
|
||||
function smtp_expect($socket, $code)
|
||||
@@ -1421,6 +1418,7 @@ function smtp_expect($socket, $code)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//end commit
|
||||
/**
|
||||
* smtp_get_admin_email
|
||||
|
||||
@@ -510,7 +510,7 @@ class MailboxHandler extends PFAHandler
|
||||
$fSubject = Config::lang('pSendmail_subject_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);
|
||||
return false;
|
||||
}
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
}
|
||||
|
||||
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));
|
||||
} else {
|
||||
flash_info(Config::lang_f('pSendmail_result_success', $fTo));
|
||||
|
||||
@@ -48,10 +48,10 @@ function sendCodebyEmail($to, $username, $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),
|
||||
Config::Lang('pPassword_welcome'),
|
||||
Config::read('admin_smtp_password'),
|
||||
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
|
||||
$elapsed_time = microtime(true) - $start_time;
|
||||
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'));
|
||||
|
||||
Reference in new issue
Block a user