mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
small change in handling recipients. ;)
git-svn-id: file:///svn/phpbb/trunk@4775 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
65f837c379
commit
d170696d68
1 changed files with 34 additions and 21 deletions
|
@ -675,7 +675,7 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
|
||||||
|
|
||||||
if ($smtp->save_session)
|
if ($smtp->save_session)
|
||||||
{
|
{
|
||||||
$smtp->fp = fopen('cache/session.txt', 'w');
|
$smtp->fp = fopen('cache/session.txt', 'a');
|
||||||
fwrite($smtp->fp, 'Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port'] . "\r\n");
|
fwrite($smtp->fp, 'Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port'] . "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,7 +701,7 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
|
||||||
|
|
||||||
// From this point onward most server response codes should be 250
|
// From this point onward most server response codes should be 250
|
||||||
// Specify who the mail is from....
|
// Specify who the mail is from....
|
||||||
$smtp->server_send('MAIL FROM: <' . $config['board_email'] . ">\r\n");
|
$smtp->server_send('MAIL FROM:<' . $config['board_email'] . ">\r\n");
|
||||||
if ($err_msg = $smtp->server_parse('250', __LINE__))
|
if ($err_msg = $smtp->server_parse('250', __LINE__))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -712,6 +712,7 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
|
||||||
$cc_header = implode(', ', $mail_cc);
|
$cc_header = implode(', ', $mail_cc);
|
||||||
|
|
||||||
// Now tell the MTA to send the Message to the following people... [TO, BCC, CC]
|
// Now tell the MTA to send the Message to the following people... [TO, BCC, CC]
|
||||||
|
$rcpt = false;
|
||||||
foreach ($mail_rcpt as $type => $mail_to_addresses)
|
foreach ($mail_rcpt as $type => $mail_to_addresses)
|
||||||
{
|
{
|
||||||
foreach ($mail_to_addresses as $mail_to_address)
|
foreach ($mail_to_addresses as $mail_to_address)
|
||||||
|
@ -719,15 +720,29 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '')
|
||||||
// Add an additional bit of error checking to the To field.
|
// Add an additional bit of error checking to the To field.
|
||||||
if (preg_match('#[^ ]+\@[^ ]+#', $mail_to_address))
|
if (preg_match('#[^ ]+\@[^ ]+#', $mail_to_address))
|
||||||
{
|
{
|
||||||
$smtp->server_send("RCPT TO: $mail_to_address\r\n");
|
$smtp->server_send("RCPT TO:$mail_to_address\r\n");
|
||||||
if ($err_msg = $smtp->server_parse('250', __LINE__))
|
if ($err_msg = $smtp->server_parse('250', __LINE__))
|
||||||
{
|
{
|
||||||
return false;
|
// We continue... if users are not resolved we do not care
|
||||||
|
if ($smtp->numeric_response_code != 550)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$rcpt = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We try to send messages even if a few people do not seem to have valid email addresses, but if no one has, we have to exit here.
|
||||||
|
if (!$rcpt)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Ok now we tell the server we are ready to start sending data
|
// Ok now we tell the server we are ready to start sending data
|
||||||
$smtp->server_send("DATA\r\n");
|
$smtp->server_send("DATA\r\n");
|
||||||
|
|
||||||
|
@ -862,7 +877,7 @@ class smtp_class
|
||||||
$response_code = $response[0];
|
$response_code = $response[0];
|
||||||
unset($response[0]);
|
unset($response[0]);
|
||||||
$this->commands[$response_code] = implode(' ', $response);
|
$this->commands[$response_code] = implode(' ', $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are not authenticated yet, something might be wrong if no username and passwd passed
|
// If we are not authenticated yet, something might be wrong if no username and passwd passed
|
||||||
if (!$username || !$password)
|
if (!$username || !$password)
|
||||||
|
@ -876,7 +891,7 @@ class smtp_class
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get best authentication method
|
// Get best authentication method
|
||||||
$available_methods = explode(' ', $this->commands['AUTH']);
|
$available_methods = explode(' ', $this->commands['AUTH']);
|
||||||
|
|
||||||
// Define the auth ordering if the default auth method was not found
|
// Define the auth ordering if the default auth method was not found
|
||||||
$auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5');
|
$auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5');
|
||||||
|
@ -901,7 +916,7 @@ class smtp_class
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$method)
|
if (!$method)
|
||||||
{
|
{
|
||||||
|
@ -1047,8 +1062,8 @@ class smtp_class
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$tokens[$matches[1]] = array($tokens[$matches[1]], preg_replace('/^"(.*)"$/', '\\1', $matches[2]));
|
$tokens[$matches[1]] = array($tokens[$matches[1]], preg_replace('/^"(.*)"$/', '\\1', $matches[2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!empty($tokens[$matches[1]])) // Any other multiple instance = failure
|
else if (!empty($tokens[$matches[1]])) // Any other multiple instance = failure
|
||||||
{
|
{
|
||||||
|
@ -1076,38 +1091,36 @@ class smtp_class
|
||||||
{
|
{
|
||||||
$tokens['maxbuf'] = 65536;
|
$tokens['maxbuf'] = 65536;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required: nonce, algorithm
|
// Required: nonce, algorithm
|
||||||
if (empty($tokens['nonce']) || empty($tokens['algorithm']))
|
if (empty($tokens['nonce']) || empty($tokens['algorithm']))
|
||||||
{
|
{
|
||||||
$tokens = array();
|
$tokens = array();
|
||||||
}
|
}
|
||||||
|
$md5_challenge = $tokens;
|
||||||
$md5_challenge = $tokens;
|
|
||||||
|
|
||||||
if (!empty($md5_challenge))
|
if (!empty($md5_challenge))
|
||||||
{
|
{
|
||||||
$str = '';
|
$str = '';
|
||||||
mt_srand((double)microtime()*10000000);
|
mt_srand( (double) microtime() * 10000000);
|
||||||
for ($i = 0; $i < 32; $i++)
|
for ($i = 0; $i < 32; $i++)
|
||||||
{
|
{
|
||||||
$str .= chr(mt_rand(0, 255));
|
$str .= chr(mt_rand(0, 255));
|
||||||
}
|
}
|
||||||
$cnonce = base64_encode($str);
|
$cnonce = base64_encode($str);
|
||||||
|
|
||||||
$digest_uri = 'smtp/' . $config['smtp_host'];
|
$digest_uri = 'smtp/' . $config['smtp_host'];
|
||||||
|
|
||||||
$auth_1 = sprintf('%s:%s:%s', pack('H32', md5(sprintf('%s:%s:%s', $username, $md5_challenge['realm'], $password))), $md5_challenge['nonce'], $cnonce);
|
$auth_1 = sprintf('%s:%s:%s', pack('H32', md5(sprintf('%s:%s:%s', $username, $md5_challenge['realm'], $password))), $md5_challenge['nonce'], $cnonce);
|
||||||
$auth_2 = 'AUTHENTICATE:' . $digest_uri;
|
$auth_2 = 'AUTHENTICATE:' . $digest_uri;
|
||||||
|
|
||||||
$response_value = md5(sprintf('%s:%s:00000001:%s:auth:%s', md5($auth_1), $md5_challenge['nonce'], $cnonce, md5($auth_2)));
|
$response_value = md5(sprintf('%s:%s:00000001:%s:auth:%s', md5($auth_1), $md5_challenge['nonce'], $cnonce, md5($auth_2)));
|
||||||
|
|
||||||
$input_string = sprintf('username="%s",realm="%s",nonce="%s",cnonce="%s",nc="00000001",qop=auth,digest-uri="%s",response=%s,%d', $username, $md5_challenge['realm'], $md5_challenge['nonce'], $cnonce, $digest_uri, $response_value, $md5_challenge['maxbuf']);
|
$input_string = sprintf('username="%s",realm="%s",nonce="%s",cnonce="%s",nc="00000001",qop=auth,digest-uri="%s",response=%s,%d', $username, $md5_challenge['realm'], $md5_challenge['nonce'], $cnonce, $digest_uri, $response_value, $md5_challenge['maxbuf']);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 'Invalid digest challenge';
|
return 'Invalid digest challenge';
|
||||||
}
|
}
|
||||||
|
|
||||||
$base64_method_digest_md5 = base64_encode($input_string);
|
$base64_method_digest_md5 = base64_encode($input_string);
|
||||||
$this->server_send($base64_method_digest_md5 . "\r\n");
|
$this->server_send($base64_method_digest_md5 . "\r\n");
|
||||||
|
|
Loading…
Add table
Reference in a new issue