Vergleich inc/mailhandlers/smtp.php - 1.8.9 - 1.8.19

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 204Zeile 204

if($this->connected())
{


if($this->connected())
{

			if(!$this->send_data('MAIL FROM:<'.$this->from.'>', '250'))

			if(!$this->send_data('MAIL FROM:<'.$this->from.'>', 250))

			{
$this->fatal_error("The mail server does not understand the MAIL FROM command. Reason: ".$this->get_error());
return false;

			{
$this->fatal_error("The mail server does not understand the MAIL FROM command. Reason: ".$this->get_error());
return false;

Zeile 215Zeile 215
			foreach($emails as $to)
{
$to = trim($to);

			foreach($emails as $to)
{
$to = trim($to);

				if(!$this->send_data('RCPT TO:<'.$to.'>', '250'))

				if(!$this->send_data('RCPT TO:<'.$to.'>', 250))

				{
$this->fatal_error("The mail server does not understand the RCPT TO command. Reason: ".$this->get_error());
return false;
}
}


				{
$this->fatal_error("The mail server does not understand the RCPT TO command. Reason: ".$this->get_error());
return false;
}
}


			if($this->send_data('DATA', '354'))

			if($this->send_data('DATA', 354))

			{
$this->send_data('Date: ' . gmdate('r'));
$this->send_data('To: ' . $this->to);

			{
$this->send_data('Date: ' . gmdate('r'));
$this->send_data('To: ' . $this->to);

Zeile 247Zeile 247
				return false;
}


				return false;
}


			$this->send_data('.', '250');

			$this->send_data('.', 250);


if(!$this->keep_alive)
{


if(!$this->keep_alive)
{

Zeile 297Zeile 297
				$helo = 'HELO';
}


				$helo = 'HELO';
}


			$data = $this->send_data("{$helo} {$this->helo}", '250');

			$data = $this->send_data("{$helo} {$this->helo}", 250);

			if(!$data)
{
$this->fatal_error("The server did not understand the {$helo} command");

			if(!$data)
{
$this->fatal_error("The server did not understand the {$helo} command");

Zeile 306Zeile 306

if($this->use_tls && preg_match("#250( |-)STARTTLS#mi", $data))
{


if($this->use_tls && preg_match("#250( |-)STARTTLS#mi", $data))
{

				if(!$this->send_data('STARTTLS', '220'))

				if(!$this->send_data('STARTTLS', 220))

				{

				{

						$this->fatal_error("The server did not understand the STARTTLS command. Reason: ".$this->get_error());

					$this->fatal_error("The server did not understand the STARTTLS command. Reason: ".$this->get_error());

					return false;
}
if(!@stream_socket_enable_crypto($this->connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))

					return false;
}
if(!@stream_socket_enable_crypto($this->connection, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))

Zeile 317Zeile 317
					return false;
}
// Resend EHLO to get updated service list

					return false;
}
// Resend EHLO to get updated service list

				$data = $this->send_data("{$helo} {$this->helo}", '250');

				$data = $this->send_data("{$helo} {$this->helo}", 250);

				if(!$data)
{
$this->fatal_error("The server did not understand the EHLO command");

				if(!$data)
{
$this->fatal_error("The server did not understand the EHLO command");

Zeile 327Zeile 327

if(!empty($this->username) && !empty($this->password))
{


if(!empty($this->username) && !empty($this->password))
{

				preg_match("#250( |-)AUTH( |=)(.+)$#mi", $data, $matches);





				if(!preg_match("#250( |-)AUTH( |=)(.+)$#mi", $data, $matches))
{
$this->fatal_error("The server did not understand the AUTH command");
return false;
}

				if(!$this->auth($matches[3]))
{
return false;
}
}
return true;

				if(!$this->auth($matches[3]))
{
return false;
}
}
return true;

		}

		}

		else
{
$this->fatal_error("Unable to connect to the mail server with the given details. Reason: {$error_number}: {$error_string}");

		else
{
$this->fatal_error("Unable to connect to the mail server with the given details. Reason: {$error_number}: {$error_string}");

Zeile 351Zeile 355
	function auth($auth_methods)
{
global $lang, $mybb;

	function auth($auth_methods)
{
global $lang, $mybb;


$auth_methods = explode(" ", trim($auth_methods));



$auth_methods = explode(" ", trim($auth_methods));


		if(in_array("LOGIN", $auth_methods))
{
if(!$this->send_data("AUTH LOGIN", 334))

		if(in_array("LOGIN", $auth_methods))
{
if(!$this->send_data("AUTH LOGIN", 334))

			{

			{

				if($this->code == 503)
{
return true;

				if($this->code == 503)
{
return true;

Zeile 366Zeile 370
				return false;
}


				return false;
}


			if(!$this->send_data(base64_encode($this->username), '334'))
{
$this->fatal_error("The SMTP server rejected the supplied SMTP username. Reason: ".$this->get_error());
return false;
}

if(!$this->send_data(base64_encode($this->password), '235'))

			if(!$this->send_data(base64_encode($this->username), 334))
{
$this->fatal_error("The SMTP server rejected the supplied SMTP username. Reason: ".$this->get_error());
return false;
}

if(!$this->send_data(base64_encode($this->password), 235))

			{
$this->fatal_error("The SMTP server rejected the supplied SMTP password. Reason: ".$this->get_error());
return false;
}
}
else if(in_array("PLAIN", $auth_methods))

			{
$this->fatal_error("The SMTP server rejected the supplied SMTP password. Reason: ".$this->get_error());
return false;
}
}
else if(in_array("PLAIN", $auth_methods))

		{
if(!$this->send_data("AUTH PLAIN", '334'))
{




















		{
if(!$this->send_data("AUTH PLAIN", 334))
{
if($this->code == 503)
{
return true;
}
$this->fatal_error("The SMTP server did not respond correctly to the AUTH PLAIN command");
return false;
}
$auth = base64_encode(chr(0).$this->username.chr(0).$this->password);
if(!$this->send_data($auth, 235))
{
$this->fatal_error("The SMTP server rejected the supplied login username and password. Reason: ".$this->get_error());
return false;
}
}
else if(in_array("CRAM-MD5", $auth_methods))
{
$data = $this->send_data("AUTH CRAM-MD5", 334);
if(!$data)
{

				if($this->code == 503)
{
return true;
}

				if($this->code == 503)
{
return true;
}

				$this->fatal_error("The SMTP server did not respond correctly to the AUTH PLAIN command");

				$this->fatal_error("The SMTP server did not respond correctly to the AUTH CRAM-MD5 command");

				return false;
}

				return false;
}

			$auth = base64_encode(chr(0).$this->username.chr(0).$this->password);





$challenge = base64_decode(substr($data, 4));
$auth = base64_encode($this->username.' '.$this->cram_md5_response($this->password, $challenge));


			if(!$this->send_data($auth, 235))
{
$this->fatal_error("The SMTP server rejected the supplied login username and password. Reason: ".$this->get_error());

			if(!$this->send_data($auth, 235))
{
$this->fatal_error("The SMTP server rejected the supplied login username and password. Reason: ".$this->get_error());

Zeile 508Zeile 534
			$this->send_data('QUIT');
fclose($this->connection);
$this->status = 0;

			$this->send_data('QUIT');
fclose($this->connection);
$this->status = 0;

		}

		}

	}

/**
* Get the last error message response from the SMTP server
*
* @return string The error message response from the SMTP server

	}

/**
* Get the last error message response from the SMTP server
*
* @return string The error message response from the SMTP server

	 */

	 */

	function get_error()
{
if(!$this->last_error)
{
$this->last_error = "N/A";

	function get_error()
{
if(!$this->last_error)
{
$this->last_error = "N/A";

		}

		}


return $this->last_error;


return $this->last_error;

	}

	}


/**
* Set the last error message response from the SMTP server
*
* @param string $error The error message response


/**
* Set the last error message response from the SMTP server
*
* @param string $error The error message response

	 */

	 */

	function set_error($error)

	function set_error($error)

	{

	{

		$this->last_error = $error;

		$this->last_error = $error;

 
	}

/**
* Generate a CRAM-MD5 response from a server challenge.
*
* @param string $password Password.
* @param string $challenge Challenge sent from SMTP server.
*
* @return string CRAM-MD5 response.
*/
function cram_md5_response($password, $challenge)
{
if(strlen($password) > 64)
{
$password = pack('H32', md5($password));
}

if(strlen($password) < 64)
{
$password = str_pad($password, 64, chr(0));
}

$k_ipad = substr($password, 0, 64) ^ str_repeat(chr(0x36), 64);
$k_opad = substr($password, 0, 64) ^ str_repeat(chr(0x5C), 64);

$inner = pack('H32', md5($k_ipad.$challenge));

return md5($k_opad.$inner);

	}
}

	}
}